#include <gmlib/number/mont256.h>
#include <gmlib/number/uint256.h>

#include <stdexcept>
#include <cstring>

using namespace number;

static std::uint8_t  P_data[32]      = {0xff,0xff,0xff,0xfe,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x00,0x00,0x00,0x00,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff};
static std::uint8_t  P_SUB2_data[32] = {0xff,0xff,0xff,0xfe,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x00,0x00,0x00,0x00,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xfd};
static std::uint8_t  R_data[32]      = {0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xff,0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01};
static std::uint8_t  R_POW2_data[32] = {0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x02,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x02,0xff,0xff,0xff,0xff,0x00,0x00,0x00,0x02,0x00,0x00,0x00,0x03};
static std::uint8_t  N_data[32]      = {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01};

void test_mont256_div2()
{
    uint256_t P, P_SUB2, R, R_POW2, N_;
    uint256_from_bytes(P, P_data);
    uint256_from_bytes(P_SUB2, P_SUB2_data);
    uint256_from_bytes(R, R_data);
    uint256_from_bytes(R_POW2, R_POW2_data);
    uint256_from_bytes(N_, N_data);

    Mont256CTX ctx;
    ctx.P = P, ctx.P_SUB2 = P_SUB2;
    ctx.R = R, ctx.R_POW2 = R_POW2;
    ctx.N_ = N_;

    mont256_t    num, ret;
    std::uint8_t ret_data[32];

    std::uint8_t num0[32] = {0xd2,0x3f,0x08,0x24,0x12,0x8b,0x2f,0x33,0x0c,0x5c,0x7f,0xd0,0xa6,0xa3,0xa4,0x50,0x65,0x13,0x27,0x0e,0x26,0x9e,0x0d,0x37,0xf2,0xa7,0x4d,0xe4,0x52,0xe6,0xb4,0x38};
    std::uint8_t ret0[32] = {0x69,0x1f,0x84,0x12,0x09,0x45,0x97,0x99,0x86,0x2e,0x3f,0xe8,0x53,0x51,0xd2,0x28,0x32,0x89,0x93,0x87,0x13,0x4f,0x06,0x9b,0xf9,0x53,0xa6,0xf2,0x29,0x73,0x5a,0x1c};
    mont256_from_bytes(&ctx, num, num0);
    mont256_div2(&ctx, ret, num);
    mont256_to_bytes(&ctx, ret_data, ret);
    if (std::memcmp(ret0, ret_data, 32) != 0)
    {
        throw std::runtime_error("err in mont256_div2");
    }
    std::uint8_t num1[32] = {0x36,0xf6,0x75,0xcc,0x81,0xe7,0x4e,0xf5,0xe8,0xe2,0x5d,0x94,0x0e,0xd9,0x04,0x75,0x95,0x31,0x98,0x5d,0x5d,0x9d,0xc9,0xf8,0x18,0x18,0xe8,0x11,0x89,0x2f,0x90,0x2b};
    std::uint8_t ret1[32] = {0x9b,0x7b,0x3a,0xe5,0xc0,0xf3,0xa7,0x7a,0xf4,0x71,0x2e,0xca,0x07,0x6c,0x82,0x3a,0xca,0x98,0xcc,0x2e,0x2e,0xce,0xe4,0xfc,0x8c,0x0c,0x74,0x08,0xc4,0x97,0xc8,0x15};
    mont256_from_bytes(&ctx, num, num1);
    mont256_div2(&ctx, ret, num);
    mont256_to_bytes(&ctx, ret_data, ret);
    if (std::memcmp(ret1, ret_data, 32) != 0)
    {
        throw std::runtime_error("err in mont256_div2");
    }
    std::uint8_t num2[32] = {0x8d,0x11,0x6e,0xce,0x17,0x38,0xf7,0xd9,0x3d,0x9c,0x17,0x24,0x11,0xe2,0x0b,0x8f,0x6b,0x0d,0x54,0x9b,0x6f,0x03,0x67,0x5a,0x16,0x00,0xa3,0x5a,0x09,0x99,0x50,0xd8};
    std::uint8_t ret2[32] = {0x46,0x88,0xb7,0x67,0x0b,0x9c,0x7b,0xec,0x9e,0xce,0x0b,0x92,0x08,0xf1,0x05,0xc7,0xb5,0x86,0xaa,0x4d,0xb7,0x81,0xb3,0xad,0x0b,0x00,0x51,0xad,0x04,0xcc,0xa8,0x6c};
    mont256_from_bytes(&ctx, num, num2);
    mont256_div2(&ctx, ret, num);
    mont256_to_bytes(&ctx, ret_data, ret);
    if (std::memcmp(ret2, ret_data, 32) != 0)
    {
        throw std::runtime_error("err in mont256_div2");
    }
    std::uint8_t num3[32] = {0xa1,0x70,0xb3,0x38,0x39,0x26,0x30,0x59,0xf2,0x8c,0x10,0x5d,0x1f,0xb1,0x7c,0x23,0x90,0xc1,0x92,0xcf,0xd3,0xac,0x94,0xaf,0x0f,0x21,0xdd,0xb6,0x6c,0xad,0x4a,0x26};
    std::uint8_t ret3[32] = {0x50,0xb8,0x59,0x9c,0x1c,0x93,0x18,0x2c,0xf9,0x46,0x08,0x2e,0x8f,0xd8,0xbe,0x11,0xc8,0x60,0xc9,0x67,0xe9,0xd6,0x4a,0x57,0x87,0x90,0xee,0xdb,0x36,0x56,0xa5,0x13};
    mont256_from_bytes(&ctx, num, num3);
    mont256_div2(&ctx, ret, num);
    mont256_to_bytes(&ctx, ret_data, ret);
    if (std::memcmp(ret3, ret_data, 32) != 0)
    {
        throw std::runtime_error("err in mont256_div2");
    }
    std::uint8_t num4[32] = {0x0c,0xb1,0xe2,0x9c,0x65,0x8c,0xda,0x14,0x95,0xe6,0x0a,0xf5,0x93,0xbd,0x04,0xcf,0x0f,0xd6,0x30,0xf1,0xf2,0x9d,0x0d,0xa9,0x95,0x3f,0x48,0xf1,0xa0,0x9f,0x76,0xb5};
    std::uint8_t ret4[32] = {0x86,0x58,0xf1,0x4d,0xb2,0xc6,0x6d,0x0a,0x4a,0xf3,0x05,0x7a,0xc9,0xde,0x82,0x67,0x87,0xeb,0x18,0x78,0x79,0x4e,0x86,0xd5,0x4a,0x9f,0xa4,0x78,0xd0,0x4f,0xbb,0x5a};
    mont256_from_bytes(&ctx, num, num4);
    mont256_div2(&ctx, ret, num);
    mont256_to_bytes(&ctx, ret_data, ret);
    if (std::memcmp(ret4, ret_data, 32) != 0)
    {
        throw std::runtime_error("err in mont256_div2");
    }
    std::uint8_t num5[32] = {0x6b,0x4c,0xb2,0x42,0x4a,0x23,0xd5,0x96,0x22,0x17,0xbe,0xad,0xdb,0xc4,0x96,0xcb,0x8e,0x81,0x97,0x3e,0x0b,0xec,0xd7,0xb0,0x38,0x98,0xd1,0x90,0xf9,0xeb,0xda,0xcc};
    std::uint8_t ret5[32] = {0x35,0xa6,0x59,0x21,0x25,0x11,0xea,0xcb,0x11,0x0b,0xdf,0x56,0xed,0xe2,0x4b,0x65,0xc7,0x40,0xcb,0x9f,0x05,0xf6,0x6b,0xd8,0x1c,0x4c,0x68,0xc8,0x7c,0xf5,0xed,0x66};
    mont256_from_bytes(&ctx, num, num5);
    mont256_div2(&ctx, ret, num);
    mont256_to_bytes(&ctx, ret_data, ret);
    if (std::memcmp(ret5, ret_data, 32) != 0)
    {
        throw std::runtime_error("err in mont256_div2");
    }
    std::uint8_t num6[32] = {0xae,0x97,0xba,0x94,0xd0,0xed,0xa8,0x2f,0x8f,0x6d,0x05,0x58,0x4e,0xf8,0xaa,0x38,0x92,0x27,0x66,0x58,0x1e,0x27,0xa1,0xc0,0x8a,0x6a,0x63,0xec,0x24,0xed,0xe6,0xa4};
    std::uint8_t ret6[32] = {0x57,0x4b,0xdd,0x4a,0x68,0x76,0xd4,0x17,0xc7,0xb6,0x82,0xac,0x27,0x7c,0x55,0x1c,0x49,0x13,0xb3,0x2c,0x0f,0x13,0xd0,0xe0,0x45,0x35,0x31,0xf6,0x12,0x76,0xf3,0x52};
    mont256_from_bytes(&ctx, num, num6);
    mont256_div2(&ctx, ret, num);
    mont256_to_bytes(&ctx, ret_data, ret);
    if (std::memcmp(ret6, ret_data, 32) != 0)
    {
        throw std::runtime_error("err in mont256_div2");
    }
    std::uint8_t num7[32] = {0x18,0xf1,0x35,0xd2,0x5f,0x55,0x72,0x03,0x30,0x18,0x50,0xc5,0xa3,0x8f,0xd5,0x47,0x92,0x3a,0x73,0x69,0x94,0xe3,0xbf,0x91,0x1a,0x61,0xdb,0xe2,0x2e,0x44,0x15,0x8b};
    std::uint8_t ret7[32] = {0x8c,0x78,0x9a,0xe8,0xaf,0xaa,0xb9,0x01,0x98,0x0c,0x28,0x62,0xd1,0xc7,0xea,0xa3,0xc9,0x1d,0x39,0xb4,0x4a,0x71,0xdf,0xc9,0x0d,0x30,0xed,0xf1,0x17,0x22,0x0a,0xc5};
    mont256_from_bytes(&ctx, num, num7);
    mont256_div2(&ctx, ret, num);
    mont256_to_bytes(&ctx, ret_data, ret);
    if (std::memcmp(ret7, ret_data, 32) != 0)
    {
        throw std::runtime_error("err in mont256_div2");
    }
    std::uint8_t num8[32] = {0x7f,0x15,0x05,0x24,0x34,0xb9,0xb5,0xdf,0x9e,0x77,0x69,0xb1,0x0f,0x42,0x05,0xb4,0x90,0x7a,0x70,0xc3,0x10,0x12,0xf0,0x37,0xb6,0x4c,0xe4,0x22,0x8c,0x38,0xfb,0x29};
    std::uint8_t ret8[32] = {0xbf,0x8a,0x82,0x91,0x9a,0x5c,0xda,0xef,0xcf,0x3b,0xb4,0xd8,0x87,0xa1,0x02,0xda,0x48,0x3d,0x38,0x61,0x08,0x09,0x78,0x1c,0x5b,0x26,0x72,0x11,0x46,0x1c,0x7d,0x94};
    mont256_from_bytes(&ctx, num, num8);
    mont256_div2(&ctx, ret, num);
    mont256_to_bytes(&ctx, ret_data, ret);
    if (std::memcmp(ret8, ret_data, 32) != 0)
    {
        throw std::runtime_error("err in mont256_div2");
    }
    std::uint8_t num9[32] = {0xec,0x66,0xa7,0x87,0x95,0xe7,0x61,0xd1,0x77,0x31,0xaf,0x10,0x50,0x6b,0xf2,0xef,0xc6,0xf8,0x77,0x18,0x6d,0x76,0xb0,0x7e,0x88,0x1e,0xd1,0x62,0xae,0x2e,0xb1,0x54};
    std::uint8_t ret9[32] = {0x76,0x33,0x53,0xc3,0xca,0xf3,0xb0,0xe8,0xbb,0x98,0xd7,0x88,0x28,0x35,0xf9,0x77,0xe3,0x7c,0x3b,0x8c,0x36,0xbb,0x58,0x3f,0x44,0x0f,0x68,0xb1,0x57,0x17,0x58,0xaa};
    mont256_from_bytes(&ctx, num, num9);
    mont256_div2(&ctx, ret, num);
    mont256_to_bytes(&ctx, ret_data, ret);
    if (std::memcmp(ret9, ret_data, 32) != 0)
    {
        throw std::runtime_error("err in mont256_div2");
    }
    std::uint8_t num10[32] = {0xc7,0xa2,0xea,0x20,0xb2,0xf1,0x4c,0x94,0x2e,0x05,0x31,0x9a,0xcb,0x5c,0x74,0x27,0x3f,0x98,0xe2,0x77,0x4c,0xbd,0x87,0xad,0x5c,0x90,0xa9,0x58,0x74,0x03,0xe4,0x30};
    std::uint8_t ret10[32] = {0x63,0xd1,0x75,0x10,0x59,0x78,0xa6,0x4a,0x17,0x02,0x98,0xcd,0x65,0xae,0x3a,0x13,0x9f,0xcc,0x71,0x3b,0xa6,0x5e,0xc3,0xd6,0xae,0x48,0x54,0xac,0x3a,0x01,0xf2,0x18};
    mont256_from_bytes(&ctx, num, num10);
    mont256_div2(&ctx, ret, num);
    mont256_to_bytes(&ctx, ret_data, ret);
    if (std::memcmp(ret10, ret_data, 32) != 0)
    {
        throw std::runtime_error("err in mont256_div2");
    }
    std::uint8_t num11[32] = {0x57,0xee,0x05,0xcd,0xe0,0x09,0x02,0xc7,0x7e,0xbf,0xf2,0x06,0x86,0x73,0x47,0x21,0x4c,0xdd,0x20,0x55,0x93,0x0d,0x6e,0xaf,0x14,0xf4,0x73,0x3f,0x3e,0x7d,0x1b,0xfb};
    std::uint8_t ret11[32] = {0xab,0xf7,0x02,0xe6,0x70,0x04,0x81,0x63,0xbf,0x5f,0xf9,0x03,0x43,0x39,0xa3,0x90,0xa6,0x6e,0x90,0x2a,0x49,0x86,0xb7,0x58,0x0a,0x7a,0x39,0x9f,0x9f,0x3e,0x8d,0xfd};
    mont256_from_bytes(&ctx, num, num11);
    mont256_div2(&ctx, ret, num);
    mont256_to_bytes(&ctx, ret_data, ret);
    if (std::memcmp(ret11, ret_data, 32) != 0)
    {
        throw std::runtime_error("err in mont256_div2");
    }
    std::uint8_t num12[32] = {0x83,0x0e,0x07,0xbc,0x1e,0x39,0x8f,0x10,0x12,0xbd,0x4a,0xce,0xfa,0xec,0xbd,0x38,0x9b,0xe4,0xbc,0xfc,0x49,0xb6,0x4a,0x08,0x72,0xe6,0xcc,0x3a,0xba,0xbc,0xed,0x20};
    std::uint8_t ret12[32] = {0x41,0x87,0x03,0xde,0x0f,0x1c,0xc7,0x88,0x09,0x5e,0xa5,0x67,0x7d,0x76,0x5e,0x9c,0x4d,0xf2,0x5e,0x7e,0x24,0xdb,0x25,0x04,0x39,0x73,0x66,0x1d,0x5d,0x5e,0x76,0x90};
    mont256_from_bytes(&ctx, num, num12);
    mont256_div2(&ctx, ret, num);
    mont256_to_bytes(&ctx, ret_data, ret);
    if (std::memcmp(ret12, ret_data, 32) != 0)
    {
        throw std::runtime_error("err in mont256_div2");
    }
    std::uint8_t num13[32] = {0x6b,0xf4,0x6c,0x69,0x7d,0x2c,0xaf,0x82,0xee,0xea,0xcb,0xe2,0x26,0xe8,0x75,0x55,0x57,0x90,0xf8,0x2e,0xc1,0xd3,0xfc,0xff,0x2a,0x3a,0xf4,0xd4,0x6b,0x0a,0x18,0xe8};
    std::uint8_t ret13[32] = {0x35,0xfa,0x36,0x34,0xbe,0x96,0x57,0xc1,0x77,0x75,0x65,0xf1,0x13,0x74,0x3a,0xaa,0xab,0xc8,0x7c,0x17,0x60,0xe9,0xfe,0x7f,0x95,0x1d,0x7a,0x6a,0x35,0x85,0x0c,0x74};
    mont256_from_bytes(&ctx, num, num13);
    mont256_div2(&ctx, ret, num);
    mont256_to_bytes(&ctx, ret_data, ret);
    if (std::memcmp(ret13, ret_data, 32) != 0)
    {
        throw std::runtime_error("err in mont256_div2");
    }
    std::uint8_t num14[32] = {0xca,0x02,0x13,0x5e,0x92,0xb1,0xd3,0xf2,0x8e,0xde,0x0d,0x7a,0xc3,0xba,0xea,0x9e,0x13,0xde,0xef,0x86,0xab,0x10,0x31,0xd0,0xf6,0x46,0xe1,0xf4,0x0a,0x09,0x7c,0x97};
    std::uint8_t ret14[32] = {0xe5,0x01,0x09,0xae,0xc9,0x58,0xe9,0xf9,0x47,0x6f,0x06,0xbd,0x61,0xdd,0x75,0x4f,0x09,0xef,0x77,0xc2,0xd5,0x88,0x18,0xe8,0xfb,0x23,0x70,0xfa,0x05,0x04,0xbe,0x4b};
    mont256_from_bytes(&ctx, num, num14);
    mont256_div2(&ctx, ret, num);
    mont256_to_bytes(&ctx, ret_data, ret);
    if (std::memcmp(ret14, ret_data, 32) != 0)
    {
        throw std::runtime_error("err in mont256_div2");
    }
    std::uint8_t num15[32] = {0x7f,0x26,0x14,0x4b,0x98,0x28,0x9f,0xcd,0x59,0xa5,0x4a,0x7b,0xb1,0xfe,0xe0,0x8f,0x57,0x12,0x42,0x42,0x50,0x51,0xc1,0xcc,0xd1,0x7f,0x9a,0xca,0xe0,0x1f,0x50,0x57};
    std::uint8_t ret15[32] = {0xbf,0x93,0x0a,0x25,0x4c,0x14,0x4f,0xe6,0xac,0xd2,0xa5,0x3d,0xd8,0xff,0x70,0x47,0xab,0x89,0x21,0x20,0xa8,0x28,0xe0,0xe6,0xe8,0xbf,0xcd,0x65,0x70,0x0f,0xa8,0x2b};
    mont256_from_bytes(&ctx, num, num15);
    mont256_div2(&ctx, ret, num);
    mont256_to_bytes(&ctx, ret_data, ret);
    if (std::memcmp(ret15, ret_data, 32) != 0)
    {
        throw std::runtime_error("err in mont256_div2");
    }
    std::uint8_t num16[32] = {0x45,0x1a,0xbd,0x81,0xf1,0xd6,0x9e,0xd6,0x17,0xf5,0xe8,0x37,0xd7,0x08,0x20,0xfe,0x11,0x9a,0x72,0xd1,0x74,0xc9,0xdf,0x6a,0xcc,0x01,0x1c,0xdd,0x94,0x74,0x03,0x1b};
    std::uint8_t ret16[32] = {0xa2,0x8d,0x5e,0xc0,0x78,0xeb,0x4f,0x6b,0x0b,0xfa,0xf4,0x1b,0xeb,0x84,0x10,0x7f,0x08,0xcd,0x39,0x68,0x3a,0x64,0xef,0xb5,0xe6,0x00,0x8e,0x6e,0xca,0x3a,0x01,0x8d};
    mont256_from_bytes(&ctx, num, num16);
    mont256_div2(&ctx, ret, num);
    mont256_to_bytes(&ctx, ret_data, ret);
    if (std::memcmp(ret16, ret_data, 32) != 0)
    {
        throw std::runtime_error("err in mont256_div2");
    }
    std::uint8_t num17[32] = {0x4f,0x42,0x6d,0xcb,0xb3,0x94,0xfb,0x36,0xbb,0x2d,0x42,0x0f,0x0f,0x88,0x08,0x0b,0x10,0xa3,0xd6,0xb2,0xaa,0x05,0xe1,0x1a,0xb2,0x71,0x59,0x45,0x79,0x5e,0x82,0x29};
    std::uint8_t ret17[32] = {0xa7,0xa1,0x36,0xe5,0x59,0xca,0x7d,0x9b,0x5d,0x96,0xa1,0x07,0x87,0xc4,0x04,0x05,0x88,0x51,0xeb,0x58,0xd5,0x02,0xf0,0x8d,0xd9,0x38,0xac,0xa2,0xbc,0xaf,0x41,0x14};
    mont256_from_bytes(&ctx, num, num17);
    mont256_div2(&ctx, ret, num);
    mont256_to_bytes(&ctx, ret_data, ret);
    if (std::memcmp(ret17, ret_data, 32) != 0)
    {
        throw std::runtime_error("err in mont256_div2");
    }
    std::uint8_t num18[32] = {0xb7,0x74,0xeb,0x52,0x48,0xdb,0x40,0xaf,0x72,0x15,0x83,0x70,0xd2,0x69,0xa9,0xa5,0xae,0x65,0x8f,0x33,0xfe,0x3b,0x89,0x0b,0x93,0xf4,0x48,0xb3,0xa5,0xaa,0x3c,0x81};
    std::uint8_t ret18[32] = {0xdb,0xba,0x75,0xa8,0xa4,0x6d,0xa0,0x57,0xb9,0x0a,0xc1,0xb8,0x69,0x34,0xd4,0xd2,0xd7,0x32,0xc7,0x99,0x7f,0x1d,0xc4,0x86,0x49,0xfa,0x24,0x59,0xd2,0xd5,0x1e,0x40};
    mont256_from_bytes(&ctx, num, num18);
    mont256_div2(&ctx, ret, num);
    mont256_to_bytes(&ctx, ret_data, ret);
    if (std::memcmp(ret18, ret_data, 32) != 0)
    {
        throw std::runtime_error("err in mont256_div2");
    }
    std::uint8_t num19[32] = {0x5a,0xff,0xb2,0x29,0x76,0x31,0xa9,0x92,0xf0,0xce,0x58,0x35,0x05,0xc6,0xaf,0x07,0x58,0xd5,0x56,0x3d,0xab,0x2c,0xd3,0x1e,0xe3,0x15,0x12,0x88,0x62,0xc3,0x3a,0x4f};
    std::uint8_t ret19[32] = {0xad,0x7f,0xd9,0x14,0x3b,0x18,0xd4,0xc9,0x78,0x67,0x2c,0x1a,0x82,0xe3,0x57,0x83,0xac,0x6a,0xab,0x1e,0x55,0x96,0x69,0x8f,0xf1,0x8a,0x89,0x44,0x31,0x61,0x9d,0x27};
    mont256_from_bytes(&ctx, num, num19);
    mont256_div2(&ctx, ret, num);
    mont256_to_bytes(&ctx, ret_data, ret);
    if (std::memcmp(ret19, ret_data, 32) != 0)
    {
        throw std::runtime_error("err in mont256_div2");
    }
    std::uint8_t num20[32] = {0x49,0x95,0x23,0x99,0xc4,0xaa,0xea,0xc1,0x37,0xdc,0x76,0xfb,0x0f,0x17,0xa3,0x00,0x7e,0x62,0xaa,0x0a,0x1d,0xf9,0xfd,0x78,0x9c,0x65,0x39,0x38,0x2b,0x05,0x37,0xe6};
    std::uint8_t ret20[32] = {0x24,0xca,0x91,0xcc,0xe2,0x55,0x75,0x60,0x9b,0xee,0x3b,0x7d,0x87,0x8b,0xd1,0x80,0x3f,0x31,0x55,0x05,0x0e,0xfc,0xfe,0xbc,0x4e,0x32,0x9c,0x9c,0x15,0x82,0x9b,0xf3};
    mont256_from_bytes(&ctx, num, num20);
    mont256_div2(&ctx, ret, num);
    mont256_to_bytes(&ctx, ret_data, ret);
    if (std::memcmp(ret20, ret_data, 32) != 0)
    {
        throw std::runtime_error("err in mont256_div2");
    }
    std::uint8_t num21[32] = {0x7f,0x1b,0x10,0x3c,0xdf,0x15,0x82,0xb0,0xea,0xb4,0x77,0xd2,0x64,0x15,0x47,0x9c,0x65,0xdc,0x9f,0x50,0x3f,0x63,0xaf,0x83,0xbd,0x05,0x61,0xe6,0x21,0x1c,0x70,0xcf};
    std::uint8_t ret21[32] = {0xbf,0x8d,0x88,0x1d,0xef,0x8a,0xc1,0x58,0x75,0x5a,0x3b,0xe9,0x32,0x0a,0xa3,0xce,0x32,0xee,0x4f,0xa7,0x9f,0xb1,0xd7,0xc2,0x5e,0x82,0xb0,0xf3,0x10,0x8e,0x38,0x67};
    mont256_from_bytes(&ctx, num, num21);
    mont256_div2(&ctx, ret, num);
    mont256_to_bytes(&ctx, ret_data, ret);
    if (std::memcmp(ret21, ret_data, 32) != 0)
    {
        throw std::runtime_error("err in mont256_div2");
    }
    std::uint8_t num22[32] = {0x23,0x0d,0x97,0x7e,0xe2,0x25,0x71,0x59,0x47,0x20,0x77,0x1f,0x8c,0xa8,0x18,0x11,0x66,0xd2,0x28,0x76,0x72,0xfd,0xf2,0x02,0x2a,0x96,0xfb,0x1a,0x14,0xa0,0xf9,0xe7};
    std::uint8_t ret22[32] = {0x91,0x86,0xcb,0xbe,0xf1,0x12,0xb8,0xac,0xa3,0x90,0x3b,0x8f,0xc6,0x54,0x0c,0x08,0xb3,0x69,0x14,0x3a,0xb9,0x7e,0xf9,0x01,0x95,0x4b,0x7d,0x8d,0x0a,0x50,0x7c,0xf3};
    mont256_from_bytes(&ctx, num, num22);
    mont256_div2(&ctx, ret, num);
    mont256_to_bytes(&ctx, ret_data, ret);
    if (std::memcmp(ret22, ret_data, 32) != 0)
    {
        throw std::runtime_error("err in mont256_div2");
    }
    std::uint8_t num23[32] = {0xfc,0x89,0x1b,0x4a,0x6a,0x50,0xdf,0x4d,0xb4,0xd6,0x6a,0x3a,0x47,0x46,0x9a,0x4d,0x8c,0xdb,0x30,0x5f,0xdd,0x2e,0x16,0x09,0x6e,0x36,0xaa,0xb0,0xd1,0xbc,0x52,0xd9};
    std::uint8_t ret23[32] = {0xfe,0x44,0x8d,0xa4,0xb5,0x28,0x6f,0xa6,0xda,0x6b,0x35,0x1d,0x23,0xa3,0x4d,0x26,0xc6,0x6d,0x98,0x2f,0x6e,0x97,0x0b,0x05,0x37,0x1b,0x55,0x58,0x68,0xde,0x29,0x6c};
    mont256_from_bytes(&ctx, num, num23);
    mont256_div2(&ctx, ret, num);
    mont256_to_bytes(&ctx, ret_data, ret);
    if (std::memcmp(ret23, ret_data, 32) != 0)
    {
        throw std::runtime_error("err in mont256_div2");
    }
    std::uint8_t num24[32] = {0x15,0x3e,0x7c,0x2a,0x26,0xa2,0xc0,0xbd,0x3b,0x12,0x87,0xff,0xf5,0x2d,0xdf,0x5d,0x61,0x64,0x99,0xc9,0xe2,0x5a,0x76,0x05,0xae,0xc6,0xf0,0x24,0x5b,0xd8,0x6d,0x40};
    std::uint8_t ret24[32] = {0x0a,0x9f,0x3e,0x15,0x13,0x51,0x60,0x5e,0x9d,0x89,0x43,0xff,0xfa,0x96,0xef,0xae,0xb0,0xb2,0x4c,0xe4,0xf1,0x2d,0x3b,0x02,0xd7,0x63,0x78,0x12,0x2d,0xec,0x36,0xa0};
    mont256_from_bytes(&ctx, num, num24);
    mont256_div2(&ctx, ret, num);
    mont256_to_bytes(&ctx, ret_data, ret);
    if (std::memcmp(ret24, ret_data, 32) != 0)
    {
        throw std::runtime_error("err in mont256_div2");
    }
    std::uint8_t num25[32] = {0xd4,0xc2,0x8c,0x2e,0x7c,0x26,0x84,0x7f,0x03,0x16,0x90,0x9e,0x3b,0xbb,0xe9,0xea,0xa8,0x94,0x8c,0x89,0x3b,0x61,0x86,0x76,0x26,0xbb,0x7d,0xbd,0x2d,0x1c,0x9a,0xf0};
    std::uint8_t ret25[32] = {0x6a,0x61,0x46,0x17,0x3e,0x13,0x42,0x3f,0x81,0x8b,0x48,0x4f,0x1d,0xdd,0xf4,0xf5,0x54,0x4a,0x46,0x44,0x9d,0xb0,0xc3,0x3b,0x13,0x5d,0xbe,0xde,0x96,0x8e,0x4d,0x78};
    mont256_from_bytes(&ctx, num, num25);
    mont256_div2(&ctx, ret, num);
    mont256_to_bytes(&ctx, ret_data, ret);
    if (std::memcmp(ret25, ret_data, 32) != 0)
    {
        throw std::runtime_error("err in mont256_div2");
    }
    std::uint8_t num26[32] = {0x88,0xda,0xf4,0x01,0x6b,0x40,0x13,0xef,0x25,0x4b,0x0c,0x4e,0x01,0x0c,0x47,0x59,0x48,0x2c,0x9c,0xbc,0x43,0x43,0x5c,0xc5,0x2e,0xae,0x05,0xcf,0x96,0xd0,0xcc,0x5f};
    std::uint8_t ret26[32] = {0xc4,0x6d,0x7a,0x00,0x35,0xa0,0x09,0xf7,0x92,0xa5,0x86,0x27,0x00,0x86,0x23,0xac,0xa4,0x16,0x4e,0x5d,0xa1,0xa1,0xae,0x63,0x17,0x57,0x02,0xe7,0xcb,0x68,0x66,0x2f};
    mont256_from_bytes(&ctx, num, num26);
    mont256_div2(&ctx, ret, num);
    mont256_to_bytes(&ctx, ret_data, ret);
    if (std::memcmp(ret26, ret_data, 32) != 0)
    {
        throw std::runtime_error("err in mont256_div2");
    }
    std::uint8_t num27[32] = {0xdb,0xf4,0xa8,0xb2,0xb0,0xc4,0x31,0x2d,0x20,0x20,0x36,0x26,0xf3,0xfe,0x39,0xc0,0x51,0x90,0x88,0xf5,0x90,0xfb,0xbd,0x11,0x9c,0x1c,0xaa,0xf7,0x5e,0x87,0x66,0xed};
    std::uint8_t ret27[32] = {0xed,0xfa,0x54,0x58,0xd8,0x62,0x18,0x96,0x90,0x10,0x1b,0x13,0x79,0xff,0x1c,0xe0,0x28,0xc8,0x44,0x7a,0x48,0x7d,0xde,0x89,0x4e,0x0e,0x55,0x7b,0xaf,0x43,0xb3,0x76};
    mont256_from_bytes(&ctx, num, num27);
    mont256_div2(&ctx, ret, num);
    mont256_to_bytes(&ctx, ret_data, ret);
    if (std::memcmp(ret27, ret_data, 32) != 0)
    {
        throw std::runtime_error("err in mont256_div2");
    }
    std::uint8_t num28[32] = {0x74,0xe6,0x9a,0x5d,0x0d,0xd2,0x7a,0x65,0xbd,0x62,0x88,0x81,0xad,0x1b,0x72,0xdb,0xa7,0xab,0xe1,0xc2,0x9e,0x1a,0x8e,0xf4,0xf3,0x41,0xe0,0x7a,0x83,0xf7,0x3f,0x16};
    std::uint8_t ret28[32] = {0x3a,0x73,0x4d,0x2e,0x86,0xe9,0x3d,0x32,0xde,0xb1,0x44,0x40,0xd6,0x8d,0xb9,0x6d,0xd3,0xd5,0xf0,0xe1,0x4f,0x0d,0x47,0x7a,0x79,0xa0,0xf0,0x3d,0x41,0xfb,0x9f,0x8b};
    mont256_from_bytes(&ctx, num, num28);
    mont256_div2(&ctx, ret, num);
    mont256_to_bytes(&ctx, ret_data, ret);
    if (std::memcmp(ret28, ret_data, 32) != 0)
    {
        throw std::runtime_error("err in mont256_div2");
    }
    std::uint8_t num29[32] = {0x8f,0x2c,0x6e,0xc8,0xcc,0x41,0x69,0xa3,0xae,0x3a,0x2b,0x7f,0xdf,0xe0,0x18,0x93,0xf3,0xae,0xd0,0xb6,0xc7,0xac,0x14,0x91,0xde,0xf8,0x83,0x34,0xe6,0x47,0xcb,0x8f};
    std::uint8_t ret29[32] = {0xc7,0x96,0x37,0x63,0xe6,0x20,0xb4,0xd1,0xd7,0x1d,0x15,0xbf,0xef,0xf0,0x0c,0x49,0xf9,0xd7,0x68,0x5a,0xe3,0xd6,0x0a,0x49,0x6f,0x7c,0x41,0x9a,0x73,0x23,0xe5,0xc7};
    mont256_from_bytes(&ctx, num, num29);
    mont256_div2(&ctx, ret, num);
    mont256_to_bytes(&ctx, ret_data, ret);
    if (std::memcmp(ret29, ret_data, 32) != 0)
    {
        throw std::runtime_error("err in mont256_div2");
    }
    std::uint8_t num30[32] = {0x66,0x83,0x68,0x86,0xa2,0x60,0xcd,0x0b,0x7b,0x45,0x14,0x5c,0x1a,0x81,0x68,0x2c,0x64,0xe5,0x0c,0xad,0x66,0x23,0x7a,0x04,0x65,0xe7,0xe4,0x23,0x64,0x72,0xf1,0xa3};
    std::uint8_t ret30[32] = {0xb3,0x41,0xb4,0x42,0xd1,0x30,0x66,0x85,0xbd,0xa2,0x8a,0x2e,0x0d,0x40,0xb4,0x16,0x32,0x72,0x86,0x56,0x33,0x11,0xbd,0x02,0xb2,0xf3,0xf2,0x11,0xb2,0x39,0x78,0xd1};
    mont256_from_bytes(&ctx, num, num30);
    mont256_div2(&ctx, ret, num);
    mont256_to_bytes(&ctx, ret_data, ret);
    if (std::memcmp(ret30, ret_data, 32) != 0)
    {
        throw std::runtime_error("err in mont256_div2");
    }
    std::uint8_t num31[32] = {0x1c,0x24,0x42,0xf9,0x29,0x8c,0xb3,0xa5,0x70,0xcc,0xec,0x31,0x35,0x71,0x81,0x0a,0xfc,0x13,0x2d,0x0d,0x11,0x3d,0xb1,0x7d,0x30,0xcb,0xc9,0x7d,0x0f,0xef,0x79,0x28};
    std::uint8_t ret31[32] = {0x0e,0x12,0x21,0x7c,0x94,0xc6,0x59,0xd2,0xb8,0x66,0x76,0x18,0x9a,0xb8,0xc0,0x85,0x7e,0x09,0x96,0x86,0x88,0x9e,0xd8,0xbe,0x98,0x65,0xe4,0xbe,0x87,0xf7,0xbc,0x94};
    mont256_from_bytes(&ctx, num, num31);
    mont256_div2(&ctx, ret, num);
    mont256_to_bytes(&ctx, ret_data, ret);
    if (std::memcmp(ret31, ret_data, 32) != 0)
    {
        throw std::runtime_error("err in mont256_div2");
    }
    std::uint8_t num32[32] = {0x89,0x5f,0xd7,0xb3,0x26,0xb9,0x4c,0x7f,0x91,0x18,0xbb,0x16,0x00,0x0f,0x49,0xc8,0x1a,0x35,0x8c,0xa0,0x0d,0x75,0x98,0x5d,0x99,0xc9,0x43,0x09,0x57,0x0d,0xc1,0x95};
    std::uint8_t ret32[32] = {0xc4,0xaf,0xeb,0xd9,0x13,0x5c,0xa6,0x3f,0xc8,0x8c,0x5d,0x8b,0x00,0x07,0xa4,0xe4,0x0d,0x1a,0xc6,0x4f,0x86,0xba,0xcc,0x2f,0x4c,0xe4,0xa1,0x84,0xab,0x86,0xe0,0xca};
    mont256_from_bytes(&ctx, num, num32);
    mont256_div2(&ctx, ret, num);
    mont256_to_bytes(&ctx, ret_data, ret);
    if (std::memcmp(ret32, ret_data, 32) != 0)
    {
        throw std::runtime_error("err in mont256_div2");
    }
    std::uint8_t num33[32] = {0x35,0x3c,0x63,0x1c,0xdf,0xd4,0x3f,0x37,0x12,0x00,0x33,0x9d,0x06,0x87,0x39,0xfa,0x9d,0x1d,0xe2,0xa0,0x5d,0x15,0x8a,0x2f,0xf2,0xee,0x4e,0x45,0x19,0xf9,0x91,0x9c};
    std::uint8_t ret33[32] = {0x1a,0x9e,0x31,0x8e,0x6f,0xea,0x1f,0x9b,0x89,0x00,0x19,0xce,0x83,0x43,0x9c,0xfd,0x4e,0x8e,0xf1,0x50,0x2e,0x8a,0xc5,0x17,0xf9,0x77,0x27,0x22,0x8c,0xfc,0xc8,0xce};
    mont256_from_bytes(&ctx, num, num33);
    mont256_div2(&ctx, ret, num);
    mont256_to_bytes(&ctx, ret_data, ret);
    if (std::memcmp(ret33, ret_data, 32) != 0)
    {
        throw std::runtime_error("err in mont256_div2");
    }
    std::uint8_t num34[32] = {0x9a,0x2e,0xf8,0x0f,0x58,0xee,0x85,0x71,0xf4,0x99,0x8d,0x7c,0x40,0x93,0xf6,0xde,0xa2,0x68,0xaa,0x87,0x26,0x07,0x67,0x9d,0x60,0x50,0x91,0x4a,0x9d,0x33,0xa0,0x1c};
    std::uint8_t ret34[32] = {0x4d,0x17,0x7c,0x07,0xac,0x77,0x42,0xb8,0xfa,0x4c,0xc6,0xbe,0x20,0x49,0xfb,0x6f,0x51,0x34,0x55,0x43,0x93,0x03,0xb3,0xce,0xb0,0x28,0x48,0xa5,0x4e,0x99,0xd0,0x0e};
    mont256_from_bytes(&ctx, num, num34);
    mont256_div2(&ctx, ret, num);
    mont256_to_bytes(&ctx, ret_data, ret);
    if (std::memcmp(ret34, ret_data, 32) != 0)
    {
        throw std::runtime_error("err in mont256_div2");
    }
    std::uint8_t num35[32] = {0xfa,0x52,0x9b,0xa3,0xfe,0x3b,0xfa,0xda,0x7c,0xf2,0x07,0x24,0xd9,0x53,0xee,0x26,0x1d,0x87,0xce,0xc3,0x1f,0x72,0x96,0xab,0x79,0x61,0xfd,0x92,0x5d,0x39,0xd0,0xa8};
    std::uint8_t ret35[32] = {0x7d,0x29,0x4d,0xd1,0xff,0x1d,0xfd,0x6d,0x3e,0x79,0x03,0x92,0x6c,0xa9,0xf7,0x13,0x0e,0xc3,0xe7,0x61,0x8f,0xb9,0x4b,0x55,0xbc,0xb0,0xfe,0xc9,0x2e,0x9c,0xe8,0x54};
    mont256_from_bytes(&ctx, num, num35);
    mont256_div2(&ctx, ret, num);
    mont256_to_bytes(&ctx, ret_data, ret);
    if (std::memcmp(ret35, ret_data, 32) != 0)
    {
        throw std::runtime_error("err in mont256_div2");
    }
    std::uint8_t num36[32] = {0xbf,0xea,0xa1,0x55,0x1a,0x28,0xf7,0xb3,0x24,0xe4,0xe2,0x5a,0x15,0xfc,0x89,0x9e,0x4f,0xd5,0x8d,0xbe,0x7b,0xdc,0x96,0x8b,0x7a,0xfb,0x2c,0x68,0x77,0x4b,0x15,0xd7};
    std::uint8_t ret36[32] = {0xdf,0xf5,0x50,0xaa,0x0d,0x14,0x7b,0xd9,0x92,0x72,0x71,0x2d,0x0a,0xfe,0x44,0xcf,0x27,0xea,0xc6,0xde,0xbd,0xee,0x4b,0x46,0x3d,0x7d,0x96,0x34,0x3b,0xa5,0x8a,0xeb};
    mont256_from_bytes(&ctx, num, num36);
    mont256_div2(&ctx, ret, num);
    mont256_to_bytes(&ctx, ret_data, ret);
    if (std::memcmp(ret36, ret_data, 32) != 0)
    {
        throw std::runtime_error("err in mont256_div2");
    }
    std::uint8_t num37[32] = {0x84,0x2e,0x7f,0xc2,0x29,0x54,0x0a,0x6e,0xb1,0x2a,0xa1,0xf6,0xd4,0x2f,0xdd,0xbb,0x7a,0x86,0xf7,0xa2,0x43,0xc7,0x1b,0x9a,0xbd,0x87,0xa8,0x65,0x57,0xb6,0xfb,0x7e};
    std::uint8_t ret37[32] = {0x42,0x17,0x3f,0xe1,0x14,0xaa,0x05,0x37,0x58,0x95,0x50,0xfb,0x6a,0x17,0xee,0xdd,0xbd,0x43,0x7b,0xd1,0x21,0xe3,0x8d,0xcd,0x5e,0xc3,0xd4,0x32,0xab,0xdb,0x7d,0xbf};
    mont256_from_bytes(&ctx, num, num37);
    mont256_div2(&ctx, ret, num);
    mont256_to_bytes(&ctx, ret_data, ret);
    if (std::memcmp(ret37, ret_data, 32) != 0)
    {
        throw std::runtime_error("err in mont256_div2");
    }
    std::uint8_t num38[32] = {0xb0,0xa8,0x44,0xe5,0x25,0x87,0xbe,0x6b,0x5c,0x9b,0xcf,0x35,0x87,0x3b,0xe0,0x78,0xf3,0xb7,0xa5,0x0d,0xf3,0x73,0xca,0x53,0x34,0x88,0xf8,0x76,0x05,0xe9,0x99,0xf3};
    std::uint8_t ret38[32] = {0xd8,0x54,0x22,0x72,0x12,0xc3,0xdf,0x35,0xae,0x4d,0xe7,0x9a,0xc3,0x9d,0xf0,0x3c,0x79,0xdb,0xd2,0x86,0x79,0xb9,0xe5,0x2a,0x1a,0x44,0x7c,0x3b,0x02,0xf4,0xcc,0xf9};
    mont256_from_bytes(&ctx, num, num38);
    mont256_div2(&ctx, ret, num);
    mont256_to_bytes(&ctx, ret_data, ret);
    if (std::memcmp(ret38, ret_data, 32) != 0)
    {
        throw std::runtime_error("err in mont256_div2");
    }
    std::uint8_t num39[32] = {0xa4,0x96,0x36,0xa2,0xfa,0x7f,0x0e,0xab,0x4c,0x4f,0x9b,0x06,0x87,0x32,0x2e,0x25,0xc2,0x15,0xa8,0x2a,0x06,0xec,0x41,0xad,0xea,0x05,0x75,0x43,0x8b,0x0d,0x59,0x0b};
    std::uint8_t ret39[32] = {0xd2,0x4b,0x1b,0x50,0xfd,0x3f,0x87,0x55,0xa6,0x27,0xcd,0x83,0x43,0x99,0x17,0x12,0xe1,0x0a,0xd4,0x14,0x83,0x76,0x20,0xd7,0x75,0x02,0xba,0xa1,0xc5,0x86,0xac,0x85};
    mont256_from_bytes(&ctx, num, num39);
    mont256_div2(&ctx, ret, num);
    mont256_to_bytes(&ctx, ret_data, ret);
    if (std::memcmp(ret39, ret_data, 32) != 0)
    {
        throw std::runtime_error("err in mont256_div2");
    }
    std::uint8_t num40[32] = {0xe8,0x83,0xa1,0xd4,0x5d,0xe0,0x09,0x97,0x84,0xb5,0xa8,0x18,0x42,0xd8,0x72,0x08,0xd8,0x6f,0x40,0xf6,0xb2,0x39,0xf3,0xc7,0x17,0x4c,0x77,0xa2,0xdd,0x02,0xde,0x92};
    std::uint8_t ret40[32] = {0x74,0x41,0xd0,0xea,0x2e,0xf0,0x04,0xcb,0xc2,0x5a,0xd4,0x0c,0x21,0x6c,0x39,0x04,0x6c,0x37,0xa0,0x7b,0x59,0x1c,0xf9,0xe3,0x8b,0xa6,0x3b,0xd1,0x6e,0x81,0x6f,0x49};
    mont256_from_bytes(&ctx, num, num40);
    mont256_div2(&ctx, ret, num);
    mont256_to_bytes(&ctx, ret_data, ret);
    if (std::memcmp(ret40, ret_data, 32) != 0)
    {
        throw std::runtime_error("err in mont256_div2");
    }
    std::uint8_t num41[32] = {0x80,0xb0,0xc0,0x8b,0xc7,0x70,0x24,0x20,0x8a,0xa4,0x24,0x8c,0x88,0x57,0xf9,0xa4,0x39,0x08,0xf2,0x27,0xc5,0x9d,0xb9,0x16,0x5b,0x0e,0xe7,0x6f,0x2a,0xc3,0x44,0x46};
    std::uint8_t ret41[32] = {0x40,0x58,0x60,0x45,0xe3,0xb8,0x12,0x10,0x45,0x52,0x12,0x46,0x44,0x2b,0xfc,0xd2,0x1c,0x84,0x79,0x13,0xe2,0xce,0xdc,0x8b,0x2d,0x87,0x73,0xb7,0x95,0x61,0xa2,0x23};
    mont256_from_bytes(&ctx, num, num41);
    mont256_div2(&ctx, ret, num);
    mont256_to_bytes(&ctx, ret_data, ret);
    if (std::memcmp(ret41, ret_data, 32) != 0)
    {
        throw std::runtime_error("err in mont256_div2");
    }
    std::uint8_t num42[32] = {0xc2,0x21,0x6b,0x02,0xfc,0x24,0x1d,0x0b,0xc9,0xd4,0x88,0xb1,0xcf,0xbf,0x33,0x60,0x9c,0xfc,0x86,0x52,0x39,0x19,0x42,0x42,0xa2,0xed,0xdb,0xbd,0x54,0x64,0xec,0xc2};
    std::uint8_t ret42[32] = {0x61,0x10,0xb5,0x81,0x7e,0x12,0x0e,0x85,0xe4,0xea,0x44,0x58,0xe7,0xdf,0x99,0xb0,0x4e,0x7e,0x43,0x29,0x1c,0x8c,0xa1,0x21,0x51,0x76,0xed,0xde,0xaa,0x32,0x76,0x61};
    mont256_from_bytes(&ctx, num, num42);
    mont256_div2(&ctx, ret, num);
    mont256_to_bytes(&ctx, ret_data, ret);
    if (std::memcmp(ret42, ret_data, 32) != 0)
    {
        throw std::runtime_error("err in mont256_div2");
    }
    std::uint8_t num43[32] = {0xcd,0xa6,0xc6,0xfd,0xbd,0x68,0x51,0x67,0x66,0x93,0x40,0x36,0xd1,0x7e,0x44,0x97,0x3d,0x48,0x82,0xa5,0xce,0x5b,0x2a,0x92,0x31,0xf5,0x17,0x07,0xda,0x45,0xe1,0x8a};
    std::uint8_t ret43[32] = {0x66,0xd3,0x63,0x7e,0xde,0xb4,0x28,0xb3,0xb3,0x49,0xa0,0x1b,0x68,0xbf,0x22,0x4b,0x9e,0xa4,0x41,0x52,0xe7,0x2d,0x95,0x49,0x18,0xfa,0x8b,0x83,0xed,0x22,0xf0,0xc5};
    mont256_from_bytes(&ctx, num, num43);
    mont256_div2(&ctx, ret, num);
    mont256_to_bytes(&ctx, ret_data, ret);
    if (std::memcmp(ret43, ret_data, 32) != 0)
    {
        throw std::runtime_error("err in mont256_div2");
    }
    std::uint8_t num44[32] = {0xfd,0x56,0xa9,0x26,0x07,0x6b,0x3e,0x36,0xbb,0x23,0x13,0xf5,0x5b,0x06,0x25,0x8e,0x7e,0x26,0xf3,0x6a,0x84,0x83,0xf8,0xb8,0x33,0x2d,0xd3,0x31,0x3a,0x0b,0x99,0x65};
    std::uint8_t ret44[32] = {0xfe,0xab,0x54,0x92,0x83,0xb5,0x9f,0x1b,0x5d,0x91,0x89,0xfa,0xad,0x83,0x12,0xc7,0x3f,0x13,0x79,0xb4,0xc2,0x41,0xfc,0x5c,0x99,0x96,0xe9,0x98,0x9d,0x05,0xcc,0xb2};
    mont256_from_bytes(&ctx, num, num44);
    mont256_div2(&ctx, ret, num);
    mont256_to_bytes(&ctx, ret_data, ret);
    if (std::memcmp(ret44, ret_data, 32) != 0)
    {
        throw std::runtime_error("err in mont256_div2");
    }
    std::uint8_t num45[32] = {0x9a,0xea,0x64,0x29,0xb1,0x49,0x1e,0x24,0x31,0x92,0xb7,0x04,0x42,0x59,0x40,0x52,0x78,0xe4,0xb9,0x8d,0x47,0x87,0xf9,0x3b,0xca,0x44,0xeb,0x86,0x07,0x26,0xe2,0x5c};
    std::uint8_t ret45[32] = {0x4d,0x75,0x32,0x14,0xd8,0xa4,0x8f,0x12,0x18,0xc9,0x5b,0x82,0x21,0x2c,0xa0,0x29,0x3c,0x72,0x5c,0xc6,0xa3,0xc3,0xfc,0x9d,0xe5,0x22,0x75,0xc3,0x03,0x93,0x71,0x2e};
    mont256_from_bytes(&ctx, num, num45);
    mont256_div2(&ctx, ret, num);
    mont256_to_bytes(&ctx, ret_data, ret);
    if (std::memcmp(ret45, ret_data, 32) != 0)
    {
        throw std::runtime_error("err in mont256_div2");
    }
    std::uint8_t num46[32] = {0x59,0x7a,0x1e,0xcf,0xfc,0xf0,0x0f,0xec,0xb9,0x1e,0xe9,0xe5,0xef,0xe0,0x9f,0x07,0xce,0xfe,0x2a,0x1f,0x72,0x7d,0x83,0x49,0x58,0x22,0xcb,0x77,0xf4,0xde,0x2c,0x08};
    std::uint8_t ret46[32] = {0x2c,0xbd,0x0f,0x67,0xfe,0x78,0x07,0xf6,0x5c,0x8f,0x74,0xf2,0xf7,0xf0,0x4f,0x83,0xe7,0x7f,0x15,0x0f,0xb9,0x3e,0xc1,0xa4,0xac,0x11,0x65,0xbb,0xfa,0x6f,0x16,0x04};
    mont256_from_bytes(&ctx, num, num46);
    mont256_div2(&ctx, ret, num);
    mont256_to_bytes(&ctx, ret_data, ret);
    if (std::memcmp(ret46, ret_data, 32) != 0)
    {
        throw std::runtime_error("err in mont256_div2");
    }
    std::uint8_t num47[32] = {0x78,0x57,0x29,0x76,0x3a,0x12,0x91,0x7c,0x1a,0x26,0xf8,0x89,0x38,0x70,0x38,0x00,0x14,0x9e,0x25,0x9b,0x5d,0x58,0xc7,0x05,0xf9,0x79,0xd0,0x4a,0xf4,0x7a,0xeb,0xdd};
    std::uint8_t ret47[32] = {0xbc,0x2b,0x94,0xba,0x9d,0x09,0x48,0xbe,0x0d,0x13,0x7c,0x44,0x9c,0x38,0x1c,0x00,0x0a,0x4f,0x12,0xcd,0x2e,0xac,0x63,0x83,0x7c,0xbc,0xe8,0x25,0x7a,0x3d,0x75,0xee};
    mont256_from_bytes(&ctx, num, num47);
    mont256_div2(&ctx, ret, num);
    mont256_to_bytes(&ctx, ret_data, ret);
    if (std::memcmp(ret47, ret_data, 32) != 0)
    {
        throw std::runtime_error("err in mont256_div2");
    }
    std::uint8_t num48[32] = {0x9c,0x3a,0x23,0xcd,0xe6,0x7a,0x9b,0x75,0xfc,0x39,0x47,0x24,0x9f,0xc2,0xd0,0xa1,0x7b,0x8f,0x2a,0xb5,0x34,0x51,0xd0,0x13,0x56,0x75,0xf6,0xad,0x32,0x5b,0x55,0xdd};
    std::uint8_t ret48[32] = {0xce,0x1d,0x11,0xe6,0x73,0x3d,0x4d,0xba,0xfe,0x1c,0xa3,0x92,0x4f,0xe1,0x68,0x50,0xbd,0xc7,0x95,0x5a,0x1a,0x28,0xe8,0x0a,0x2b,0x3a,0xfb,0x56,0x99,0x2d,0xaa,0xee};
    mont256_from_bytes(&ctx, num, num48);
    mont256_div2(&ctx, ret, num);
    mont256_to_bytes(&ctx, ret_data, ret);
    if (std::memcmp(ret48, ret_data, 32) != 0)
    {
        throw std::runtime_error("err in mont256_div2");
    }
    std::uint8_t num49[32] = {0xa4,0xa4,0x5e,0xff,0xcc,0xb5,0x73,0xd9,0x58,0x10,0xd6,0x0e,0xa7,0x29,0x91,0xb9,0xe8,0xc1,0x47,0x43,0x7a,0xbe,0xc5,0x39,0x00,0x7d,0x10,0x34,0xd7,0x26,0xc8,0x6b};
    std::uint8_t ret49[32] = {0xd2,0x52,0x2f,0x7f,0x66,0x5a,0xb9,0xec,0xac,0x08,0x6b,0x07,0x53,0x94,0xc8,0xdc,0xf4,0x60,0xa3,0xa1,0x3d,0x5f,0x62,0x9d,0x00,0x3e,0x88,0x1a,0x6b,0x93,0x64,0x35};
    mont256_from_bytes(&ctx, num, num49);
    mont256_div2(&ctx, ret, num);
    mont256_to_bytes(&ctx, ret_data, ret);
    if (std::memcmp(ret49, ret_data, 32) != 0)
    {
        throw std::runtime_error("err in mont256_div2");
    }
    std::uint8_t num50[32] = {0xb6,0x24,0x67,0x71,0xc8,0x45,0x00,0x70,0x63,0x77,0x14,0x07,0xe8,0xe7,0x27,0x89,0x1e,0xb2,0x01,0x09,0xa9,0x1c,0x24,0x39,0xd5,0xab,0x8b,0x4d,0x15,0xb4,0x0a,0xeb};
    std::uint8_t ret50[32] = {0xdb,0x12,0x33,0xb8,0x64,0x22,0x80,0x38,0x31,0xbb,0x8a,0x03,0xf4,0x73,0x93,0xc4,0x8f,0x59,0x00,0x84,0x54,0x8e,0x12,0x1d,0x6a,0xd5,0xc5,0xa6,0x8a,0xda,0x05,0x75};
    mont256_from_bytes(&ctx, num, num50);
    mont256_div2(&ctx, ret, num);
    mont256_to_bytes(&ctx, ret_data, ret);
    if (std::memcmp(ret50, ret_data, 32) != 0)
    {
        throw std::runtime_error("err in mont256_div2");
    }
    std::uint8_t num51[32] = {0xa2,0xc6,0x8e,0x45,0xca,0x04,0xc7,0x9f,0x6f,0x15,0xb6,0xad,0x2d,0xb3,0x99,0x7f,0xe3,0x96,0x39,0xbe,0x7a,0x60,0x5a,0x91,0x33,0x06,0x98,0xa1,0xc0,0x09,0x34,0x92};
    std::uint8_t ret51[32] = {0x51,0x63,0x47,0x22,0xe5,0x02,0x63,0xcf,0xb7,0x8a,0xdb,0x56,0x96,0xd9,0xcc,0xbf,0xf1,0xcb,0x1c,0xdf,0x3d,0x30,0x2d,0x48,0x99,0x83,0x4c,0x50,0xe0,0x04,0x9a,0x49};
    mont256_from_bytes(&ctx, num, num51);
    mont256_div2(&ctx, ret, num);
    mont256_to_bytes(&ctx, ret_data, ret);
    if (std::memcmp(ret51, ret_data, 32) != 0)
    {
        throw std::runtime_error("err in mont256_div2");
    }
    std::uint8_t num52[32] = {0x76,0x91,0xb0,0x6f,0x65,0x55,0xab,0xfe,0xb8,0xc9,0x81,0x7a,0xf8,0xbe,0x88,0x31,0xf2,0x37,0xe4,0x5a,0xcd,0x02,0xc5,0xe1,0x16,0x35,0x3d,0x03,0x55,0x1f,0xd8,0xf9};
    std::uint8_t ret52[32] = {0xbb,0x48,0xd8,0x37,0x32,0xaa,0xd5,0xff,0x5c,0x64,0xc0,0xbd,0x7c,0x5f,0x44,0x18,0xf9,0x1b,0xf2,0x2c,0xe6,0x81,0x62,0xf1,0x0b,0x1a,0x9e,0x81,0xaa,0x8f,0xec,0x7c};
    mont256_from_bytes(&ctx, num, num52);
    mont256_div2(&ctx, ret, num);
    mont256_to_bytes(&ctx, ret_data, ret);
    if (std::memcmp(ret52, ret_data, 32) != 0)
    {
        throw std::runtime_error("err in mont256_div2");
    }
    std::uint8_t num53[32] = {0xfe,0x3c,0x9c,0x8f,0x2b,0x85,0x5c,0x1f,0x28,0xaa,0xca,0x51,0xb9,0x8c,0x67,0xc2,0x15,0xbd,0x44,0x8f,0xf2,0x61,0x49,0xed,0xbe,0x4c,0x5c,0xe6,0x66,0xc1,0x49,0x4e};
    std::uint8_t ret53[32] = {0x7f,0x1e,0x4e,0x47,0x95,0xc2,0xae,0x0f,0x94,0x55,0x65,0x28,0xdc,0xc6,0x33,0xe1,0x0a,0xde,0xa2,0x47,0xf9,0x30,0xa4,0xf6,0xdf,0x26,0x2e,0x73,0x33,0x60,0xa4,0xa7};
    mont256_from_bytes(&ctx, num, num53);
    mont256_div2(&ctx, ret, num);
    mont256_to_bytes(&ctx, ret_data, ret);
    if (std::memcmp(ret53, ret_data, 32) != 0)
    {
        throw std::runtime_error("err in mont256_div2");
    }
    std::uint8_t num54[32] = {0xa7,0xe6,0x52,0x9b,0xce,0x76,0xe9,0xf4,0x77,0x21,0x6e,0x9e,0xe7,0xa4,0x63,0x09,0x97,0x3f,0x79,0x86,0x26,0xb1,0xcf,0xfc,0x07,0x0d,0x71,0x09,0x20,0x85,0x96,0x34};
    std::uint8_t ret54[32] = {0x53,0xf3,0x29,0x4d,0xe7,0x3b,0x74,0xfa,0x3b,0x90,0xb7,0x4f,0x73,0xd2,0x31,0x84,0xcb,0x9f,0xbc,0xc3,0x13,0x58,0xe7,0xfe,0x03,0x86,0xb8,0x84,0x90,0x42,0xcb,0x1a};
    mont256_from_bytes(&ctx, num, num54);
    mont256_div2(&ctx, ret, num);
    mont256_to_bytes(&ctx, ret_data, ret);
    if (std::memcmp(ret54, ret_data, 32) != 0)
    {
        throw std::runtime_error("err in mont256_div2");
    }
    std::uint8_t num55[32] = {0xef,0xfd,0xde,0xea,0xa8,0x42,0xbc,0x19,0x79,0x6f,0x74,0xad,0xfa,0xf5,0x54,0x96,0x98,0x8a,0xf3,0xfb,0xd3,0x96,0x30,0xd6,0x9c,0x90,0x11,0xef,0x25,0x6b,0xad,0xf9};
    std::uint8_t ret55[32] = {0xf7,0xfe,0xef,0x74,0xd4,0x21,0x5e,0x0c,0xbc,0xb7,0xba,0x56,0xfd,0x7a,0xaa,0x4b,0x4c,0x45,0x79,0xfd,0x69,0xcb,0x18,0x6b,0xce,0x48,0x08,0xf7,0x92,0xb5,0xd6,0xfc};
    mont256_from_bytes(&ctx, num, num55);
    mont256_div2(&ctx, ret, num);
    mont256_to_bytes(&ctx, ret_data, ret);
    if (std::memcmp(ret55, ret_data, 32) != 0)
    {
        throw std::runtime_error("err in mont256_div2");
    }
    std::uint8_t num56[32] = {0xcc,0xa2,0xa9,0x2b,0x03,0xa5,0x6c,0xc1,0x05,0x7a,0x40,0xb2,0x21,0x88,0x28,0x7e,0x8c,0x5c,0x71,0x5f,0x8c,0x74,0xfc,0x1e,0x27,0xe9,0xe0,0x6f,0x59,0xb4,0x4e,0x92};
    std::uint8_t ret56[32] = {0x66,0x51,0x54,0x95,0x81,0xd2,0xb6,0x60,0x82,0xbd,0x20,0x59,0x10,0xc4,0x14,0x3f,0x46,0x2e,0x38,0xaf,0xc6,0x3a,0x7e,0x0f,0x13,0xf4,0xf0,0x37,0xac,0xda,0x27,0x49};
    mont256_from_bytes(&ctx, num, num56);
    mont256_div2(&ctx, ret, num);
    mont256_to_bytes(&ctx, ret_data, ret);
    if (std::memcmp(ret56, ret_data, 32) != 0)
    {
        throw std::runtime_error("err in mont256_div2");
    }
    std::uint8_t num57[32] = {0x23,0xa5,0xef,0x88,0xef,0x02,0x09,0x0b,0xbf,0xde,0xfc,0x15,0x86,0xce,0x03,0xf9,0x1a,0x4f,0x44,0xf9,0xa6,0x51,0x14,0x45,0xb9,0xf3,0x63,0x5c,0xf8,0x8c,0x42,0x2b};
    std::uint8_t ret57[32] = {0x91,0xd2,0xf7,0xc3,0xf7,0x81,0x04,0x85,0xdf,0xef,0x7e,0x0a,0xc3,0x67,0x01,0xfc,0x8d,0x27,0xa2,0x7c,0x53,0x28,0x8a,0x23,0x5c,0xf9,0xb1,0xae,0x7c,0x46,0x21,0x15};
    mont256_from_bytes(&ctx, num, num57);
    mont256_div2(&ctx, ret, num);
    mont256_to_bytes(&ctx, ret_data, ret);
    if (std::memcmp(ret57, ret_data, 32) != 0)
    {
        throw std::runtime_error("err in mont256_div2");
    }
    std::uint8_t num58[32] = {0x07,0x2a,0x98,0xd2,0x36,0x06,0xde,0xfc,0xdf,0xb8,0x5c,0x0d,0xd3,0x7e,0xe9,0x15,0x31,0xde,0xc4,0xf4,0xdf,0x2a,0x8b,0x79,0xfc,0x8e,0x80,0xb3,0x6f,0x0e,0x22,0x89};
    std::uint8_t ret58[32] = {0x83,0x95,0x4c,0x68,0x9b,0x03,0x6f,0x7e,0x6f,0xdc,0x2e,0x06,0xe9,0xbf,0x74,0x8a,0x98,0xef,0x62,0x79,0xef,0x95,0x45,0xbd,0x7e,0x47,0x40,0x59,0xb7,0x87,0x11,0x44};
    mont256_from_bytes(&ctx, num, num58);
    mont256_div2(&ctx, ret, num);
    mont256_to_bytes(&ctx, ret_data, ret);
    if (std::memcmp(ret58, ret_data, 32) != 0)
    {
        throw std::runtime_error("err in mont256_div2");
    }
    std::uint8_t num59[32] = {0x53,0x74,0x09,0x02,0x96,0x20,0xbf,0x0d,0xc3,0x80,0x84,0xa0,0x3d,0x93,0xfd,0x4c,0x80,0x4c,0x25,0xd6,0x4a,0xff,0xdc,0xd1,0x36,0x78,0xbc,0x8d,0x40,0x78,0x3f,0x0a};
    std::uint8_t ret59[32] = {0x29,0xba,0x04,0x81,0x4b,0x10,0x5f,0x86,0xe1,0xc0,0x42,0x50,0x1e,0xc9,0xfe,0xa6,0x40,0x26,0x12,0xeb,0x25,0x7f,0xee,0x68,0x9b,0x3c,0x5e,0x46,0xa0,0x3c,0x1f,0x85};
    mont256_from_bytes(&ctx, num, num59);
    mont256_div2(&ctx, ret, num);
    mont256_to_bytes(&ctx, ret_data, ret);
    if (std::memcmp(ret59, ret_data, 32) != 0)
    {
        throw std::runtime_error("err in mont256_div2");
    }
    std::uint8_t num60[32] = {0xbd,0x6b,0x88,0x1a,0xe8,0xf6,0xe0,0xbd,0x0f,0x97,0x70,0x44,0x21,0x8e,0x0b,0x7b,0xd5,0x8d,0xcd,0xb4,0x6b,0x44,0x68,0x06,0x8b,0x5a,0xb3,0xee,0x42,0x65,0xbb,0x31};
    std::uint8_t ret60[32] = {0xde,0xb5,0xc4,0x0c,0xf4,0x7b,0x70,0x5e,0x87,0xcb,0xb8,0x22,0x10,0xc7,0x05,0xbd,0xea,0xc6,0xe6,0xd9,0xb5,0xa2,0x34,0x03,0xc5,0xad,0x59,0xf7,0x21,0x32,0xdd,0x98};
    mont256_from_bytes(&ctx, num, num60);
    mont256_div2(&ctx, ret, num);
    mont256_to_bytes(&ctx, ret_data, ret);
    if (std::memcmp(ret60, ret_data, 32) != 0)
    {
        throw std::runtime_error("err in mont256_div2");
    }
    std::uint8_t num61[32] = {0x84,0x4a,0x70,0x34,0xe7,0x7f,0xfe,0x48,0xd0,0xa6,0xec,0x17,0x95,0x56,0x58,0x5e,0xa9,0x97,0xf3,0x51,0x75,0x4a,0x09,0xcd,0xe5,0xcf,0xed,0xfa,0x5a,0x91,0x96,0xf0};
    std::uint8_t ret61[32] = {0x42,0x25,0x38,0x1a,0x73,0xbf,0xff,0x24,0x68,0x53,0x76,0x0b,0xca,0xab,0x2c,0x2f,0x54,0xcb,0xf9,0xa8,0xba,0xa5,0x04,0xe6,0xf2,0xe7,0xf6,0xfd,0x2d,0x48,0xcb,0x78};
    mont256_from_bytes(&ctx, num, num61);
    mont256_div2(&ctx, ret, num);
    mont256_to_bytes(&ctx, ret_data, ret);
    if (std::memcmp(ret61, ret_data, 32) != 0)
    {
        throw std::runtime_error("err in mont256_div2");
    }
    std::uint8_t num62[32] = {0x26,0xde,0xbf,0xdb,0x88,0x25,0xae,0x56,0x21,0x79,0xb3,0x7d,0x80,0x6c,0x10,0xb5,0xe0,0xcf,0xab,0x4c,0xea,0xef,0xc4,0xd2,0xd3,0xbf,0x6d,0x01,0x6b,0xae,0x4b,0x5b};
    std::uint8_t ret62[32] = {0x93,0x6f,0x5f,0xed,0x44,0x12,0xd7,0x2b,0x10,0xbc,0xd9,0xbe,0xc0,0x36,0x08,0x5a,0xf0,0x67,0xd5,0xa5,0xf5,0x77,0xe2,0x69,0xe9,0xdf,0xb6,0x80,0xb5,0xd7,0x25,0xad};
    mont256_from_bytes(&ctx, num, num62);
    mont256_div2(&ctx, ret, num);
    mont256_to_bytes(&ctx, ret_data, ret);
    if (std::memcmp(ret62, ret_data, 32) != 0)
    {
        throw std::runtime_error("err in mont256_div2");
    }
    std::uint8_t num63[32] = {0x9b,0xca,0x3c,0xb7,0x2e,0xe0,0x28,0x9d,0xc6,0xc9,0x1b,0x92,0x70,0xac,0x06,0xac,0xdf,0x70,0x30,0x17,0x04,0xc9,0xd7,0x8d,0x82,0xb3,0x35,0x99,0x86,0x04,0x87,0x19};
    std::uint8_t ret63[32] = {0xcd,0xe5,0x1e,0x5b,0x17,0x70,0x14,0x4e,0xe3,0x64,0x8d,0xc9,0x38,0x56,0x03,0x56,0x6f,0xb8,0x18,0x0b,0x02,0x64,0xeb,0xc7,0x41,0x59,0x9a,0xcc,0xc3,0x02,0x43,0x8c};
    mont256_from_bytes(&ctx, num, num63);
    mont256_div2(&ctx, ret, num);
    mont256_to_bytes(&ctx, ret_data, ret);
    if (std::memcmp(ret63, ret_data, 32) != 0)
    {
        throw std::runtime_error("err in mont256_div2");
    }
    std::uint8_t num64[32] = {0x9e,0x7d,0x6b,0x37,0x79,0x36,0xd5,0x36,0x24,0x3d,0x35,0x70,0x2c,0x1e,0xea,0x1f,0x26,0x59,0x74,0xa7,0xcc,0x96,0x6f,0x46,0xc6,0xaa,0x7d,0x55,0x01,0x01,0xb8,0x11};
    std::uint8_t ret64[32] = {0xcf,0x3e,0xb5,0x9b,0x3c,0x9b,0x6a,0x9b,0x12,0x1e,0x9a,0xb8,0x16,0x0f,0x75,0x0f,0x93,0x2c,0xba,0x53,0x66,0x4b,0x37,0xa3,0xe3,0x55,0x3e,0xaa,0x80,0x80,0xdc,0x08};
    mont256_from_bytes(&ctx, num, num64);
    mont256_div2(&ctx, ret, num);
    mont256_to_bytes(&ctx, ret_data, ret);
    if (std::memcmp(ret64, ret_data, 32) != 0)
    {
        throw std::runtime_error("err in mont256_div2");
    }
    std::uint8_t num65[32] = {0x87,0xdd,0xae,0xb7,0x84,0xb2,0x80,0x54,0xae,0xad,0x44,0xb0,0x53,0x73,0x90,0xe5,0x0f,0xcf,0x31,0xca,0x8e,0x75,0x2f,0xdf,0x1e,0xce,0x61,0x5d,0xb9,0xa6,0x44,0x2e};
    std::uint8_t ret65[32] = {0x43,0xee,0xd7,0x5b,0xc2,0x59,0x40,0x2a,0x57,0x56,0xa2,0x58,0x29,0xb9,0xc8,0x72,0x87,0xe7,0x98,0xe5,0x47,0x3a,0x97,0xef,0x8f,0x67,0x30,0xae,0xdc,0xd3,0x22,0x17};
    mont256_from_bytes(&ctx, num, num65);
    mont256_div2(&ctx, ret, num);
    mont256_to_bytes(&ctx, ret_data, ret);
    if (std::memcmp(ret65, ret_data, 32) != 0)
    {
        throw std::runtime_error("err in mont256_div2");
    }
    std::uint8_t num66[32] = {0x0e,0x8b,0xec,0x94,0x8f,0x6f,0x91,0x5f,0xe2,0x1b,0x37,0xca,0x1b,0x29,0xfc,0x99,0xc6,0xc8,0x0e,0x2b,0xc8,0xc6,0x14,0xb2,0x7b,0x84,0x44,0xd1,0x8e,0x31,0x70,0x41};
    std::uint8_t ret66[32] = {0x87,0x45,0xf6,0x49,0xc7,0xb7,0xc8,0xaf,0xf1,0x0d,0x9b,0xe5,0x0d,0x94,0xfe,0x4c,0xe3,0x64,0x07,0x15,0x64,0x63,0x0a,0x59,0xbd,0xc2,0x22,0x68,0xc7,0x18,0xb8,0x20};
    mont256_from_bytes(&ctx, num, num66);
    mont256_div2(&ctx, ret, num);
    mont256_to_bytes(&ctx, ret_data, ret);
    if (std::memcmp(ret66, ret_data, 32) != 0)
    {
        throw std::runtime_error("err in mont256_div2");
    }
    std::uint8_t num67[32] = {0x73,0xc1,0xcd,0x2c,0x81,0xf9,0x8b,0x52,0x19,0x05,0xd5,0x91,0xc5,0xb2,0xe7,0x5a,0x0a,0xcd,0x8b,0xe1,0x46,0xe4,0x09,0x90,0x30,0xf9,0x70,0x58,0x3f,0x9d,0x52,0xf9};
    std::uint8_t ret67[32] = {0xb9,0xe0,0xe6,0x95,0xc0,0xfc,0xc5,0xa9,0x0c,0x82,0xea,0xc8,0xe2,0xd9,0x73,0xad,0x05,0x66,0xc5,0xf0,0x23,0x72,0x04,0xc8,0x98,0x7c,0xb8,0x2c,0x1f,0xce,0xa9,0x7c};
    mont256_from_bytes(&ctx, num, num67);
    mont256_div2(&ctx, ret, num);
    mont256_to_bytes(&ctx, ret_data, ret);
    if (std::memcmp(ret67, ret_data, 32) != 0)
    {
        throw std::runtime_error("err in mont256_div2");
    }
    std::uint8_t num68[32] = {0x53,0x5b,0x6a,0x43,0x71,0x78,0xba,0x0a,0x10,0x38,0xf0,0xb5,0xe9,0x98,0xd0,0xee,0xe4,0xdd,0xf9,0xb9,0xc2,0x8e,0xe9,0x07,0x07,0x22,0x35,0xc2,0x8f,0xcd,0x7f,0x40};
    std::uint8_t ret68[32] = {0x29,0xad,0xb5,0x21,0xb8,0xbc,0x5d,0x05,0x08,0x1c,0x78,0x5a,0xf4,0xcc,0x68,0x77,0x72,0x6e,0xfc,0xdc,0xe1,0x47,0x74,0x83,0x83,0x91,0x1a,0xe1,0x47,0xe6,0xbf,0xa0};
    mont256_from_bytes(&ctx, num, num68);
    mont256_div2(&ctx, ret, num);
    mont256_to_bytes(&ctx, ret_data, ret);
    if (std::memcmp(ret68, ret_data, 32) != 0)
    {
        throw std::runtime_error("err in mont256_div2");
    }
    std::uint8_t num69[32] = {0x46,0xf5,0xa1,0xb4,0xb1,0x56,0xd1,0xad,0x33,0x0c,0x16,0xa3,0x83,0x1d,0x03,0xbf,0x9b,0x2b,0xd6,0xc0,0x81,0x6b,0xee,0x06,0xf9,0x2e,0x23,0x39,0x9c,0xce,0xa0,0x98};
    std::uint8_t ret69[32] = {0x23,0x7a,0xd0,0xda,0x58,0xab,0x68,0xd6,0x99,0x86,0x0b,0x51,0xc1,0x8e,0x81,0xdf,0xcd,0x95,0xeb,0x60,0x40,0xb5,0xf7,0x03,0x7c,0x97,0x11,0x9c,0xce,0x67,0x50,0x4c};
    mont256_from_bytes(&ctx, num, num69);
    mont256_div2(&ctx, ret, num);
    mont256_to_bytes(&ctx, ret_data, ret);
    if (std::memcmp(ret69, ret_data, 32) != 0)
    {
        throw std::runtime_error("err in mont256_div2");
    }
    std::uint8_t num70[32] = {0x3f,0x66,0x5e,0xde,0xf1,0x06,0x37,0xce,0x81,0xfc,0x06,0x9e,0x7a,0x60,0x96,0x83,0xce,0xaf,0x49,0x15,0x88,0x85,0x64,0xe8,0x82,0x16,0x85,0x8f,0x73,0xcc,0xef,0x03};
    std::uint8_t ret70[32] = {0x9f,0xb3,0x2f,0x6e,0xf8,0x83,0x1b,0xe7,0x40,0xfe,0x03,0x4f,0x3d,0x30,0x4b,0x41,0xe7,0x57,0xa4,0x8a,0x44,0x42,0xb2,0x74,0xc1,0x0b,0x42,0xc7,0xb9,0xe6,0x77,0x81};
    mont256_from_bytes(&ctx, num, num70);
    mont256_div2(&ctx, ret, num);
    mont256_to_bytes(&ctx, ret_data, ret);
    if (std::memcmp(ret70, ret_data, 32) != 0)
    {
        throw std::runtime_error("err in mont256_div2");
    }
    std::uint8_t num71[32] = {0xec,0x3b,0x96,0x05,0x42,0x74,0xa3,0xeb,0xed,0x84,0xe9,0x1e,0xf1,0x32,0xbf,0x2d,0xe0,0x40,0x01,0x5c,0xe0,0x64,0xa1,0x14,0x85,0xf1,0x11,0x5b,0xb2,0xff,0xf1,0x7b};
    std::uint8_t ret71[32] = {0xf6,0x1d,0xcb,0x02,0x21,0x3a,0x51,0xf5,0xf6,0xc2,0x74,0x8f,0x78,0x99,0x5f,0x96,0xf0,0x20,0x00,0xad,0xf0,0x32,0x50,0x8a,0xc2,0xf8,0x88,0xad,0xd9,0x7f,0xf8,0xbd};
    mont256_from_bytes(&ctx, num, num71);
    mont256_div2(&ctx, ret, num);
    mont256_to_bytes(&ctx, ret_data, ret);
    if (std::memcmp(ret71, ret_data, 32) != 0)
    {
        throw std::runtime_error("err in mont256_div2");
    }
    std::uint8_t num72[32] = {0x6a,0xa8,0xb9,0xe0,0x23,0x1b,0x3e,0x14,0x72,0x91,0x35,0xbd,0xd7,0x0a,0x39,0xd1,0x33,0xdc,0xd7,0x7f,0xf1,0x79,0xf2,0xd2,0xe4,0x8b,0x96,0x62,0x8f,0x3c,0x4b,0xe3};
    std::uint8_t ret72[32] = {0xb5,0x54,0x5c,0xef,0x91,0x8d,0x9f,0x0a,0x39,0x48,0x9a,0xde,0xeb,0x85,0x1c,0xe8,0x99,0xee,0x6b,0xbf,0x78,0xbc,0xf9,0x69,0xf2,0x45,0xcb,0x31,0x47,0x9e,0x25,0xf1};
    mont256_from_bytes(&ctx, num, num72);
    mont256_div2(&ctx, ret, num);
    mont256_to_bytes(&ctx, ret_data, ret);
    if (std::memcmp(ret72, ret_data, 32) != 0)
    {
        throw std::runtime_error("err in mont256_div2");
    }
    std::uint8_t num73[32] = {0x6d,0xa7,0x9a,0x87,0x3d,0x9a,0x80,0x79,0xab,0xd0,0xd7,0xfb,0x12,0x92,0x61,0x85,0x50,0xe4,0x0d,0x54,0x71,0x2e,0xa6,0xb3,0x64,0x71,0xfd,0xe4,0x1f,0x22,0x9d,0xd0};
    std::uint8_t ret73[32] = {0x36,0xd3,0xcd,0x43,0x9e,0xcd,0x40,0x3c,0xd5,0xe8,0x6b,0xfd,0x89,0x49,0x30,0xc2,0xa8,0x72,0x06,0xaa,0x38,0x97,0x53,0x59,0xb2,0x38,0xfe,0xf2,0x0f,0x91,0x4e,0xe8};
    mont256_from_bytes(&ctx, num, num73);
    mont256_div2(&ctx, ret, num);
    mont256_to_bytes(&ctx, ret_data, ret);
    if (std::memcmp(ret73, ret_data, 32) != 0)
    {
        throw std::runtime_error("err in mont256_div2");
    }
    std::uint8_t num74[32] = {0xc6,0xe5,0x0d,0xf2,0xe5,0xa3,0x86,0x3e,0x1f,0x52,0x52,0x65,0xc8,0xb0,0x07,0xee,0x4d,0x82,0xfe,0xac,0xab,0x62,0x86,0xcd,0x36,0x72,0xd6,0xae,0x12,0xb8,0x0a,0xed};
    std::uint8_t ret74[32] = {0xe3,0x72,0x86,0xf8,0xf2,0xd1,0xc3,0x1f,0x0f,0xa9,0x29,0x32,0xe4,0x58,0x03,0xf7,0x26,0xc1,0x7f,0x55,0xd5,0xb1,0x43,0x67,0x1b,0x39,0x6b,0x57,0x09,0x5c,0x05,0x76};
    mont256_from_bytes(&ctx, num, num74);
    mont256_div2(&ctx, ret, num);
    mont256_to_bytes(&ctx, ret_data, ret);
    if (std::memcmp(ret74, ret_data, 32) != 0)
    {
        throw std::runtime_error("err in mont256_div2");
    }
    std::uint8_t num75[32] = {0x40,0xcb,0xac,0xd0,0x24,0x9a,0x45,0x84,0x5d,0xbe,0x30,0x23,0xa9,0x06,0x92,0x2f,0xa4,0xb9,0xa9,0xc4,0xb7,0x53,0xa1,0xee,0xf0,0x83,0x60,0x85,0x27,0x89,0xd0,0x59};
    std::uint8_t ret75[32] = {0xa0,0x65,0xd6,0x67,0x92,0x4d,0x22,0xc2,0x2e,0xdf,0x18,0x11,0xd4,0x83,0x49,0x17,0xd2,0x5c,0xd4,0xe1,0xdb,0xa9,0xd0,0xf7,0xf8,0x41,0xb0,0x42,0x93,0xc4,0xe8,0x2c};
    mont256_from_bytes(&ctx, num, num75);
    mont256_div2(&ctx, ret, num);
    mont256_to_bytes(&ctx, ret_data, ret);
    if (std::memcmp(ret75, ret_data, 32) != 0)
    {
        throw std::runtime_error("err in mont256_div2");
    }
    std::uint8_t num76[32] = {0x18,0x18,0x9a,0xf4,0xf3,0xd7,0x4f,0x82,0xbf,0x26,0x8e,0xa0,0x38,0x36,0xe8,0x65,0x77,0xbd,0x89,0x1f,0xf7,0xb1,0x03,0xdf,0x23,0x23,0x1e,0x1e,0xe2,0x01,0x55,0x22};
    std::uint8_t ret76[32] = {0x0c,0x0c,0x4d,0x7a,0x79,0xeb,0xa7,0xc1,0x5f,0x93,0x47,0x50,0x1c,0x1b,0x74,0x32,0xbb,0xde,0xc4,0x8f,0xfb,0xd8,0x81,0xef,0x91,0x91,0x8f,0x0f,0x71,0x00,0xaa,0x91};
    mont256_from_bytes(&ctx, num, num76);
    mont256_div2(&ctx, ret, num);
    mont256_to_bytes(&ctx, ret_data, ret);
    if (std::memcmp(ret76, ret_data, 32) != 0)
    {
        throw std::runtime_error("err in mont256_div2");
    }
    std::uint8_t num77[32] = {0x39,0x45,0x33,0x6b,0xd5,0x1b,0x18,0x15,0xaa,0xf7,0x19,0xf3,0xfd,0x68,0x37,0x3b,0x29,0xac,0xf1,0xa5,0x7c,0xbd,0x1f,0x5a,0xe2,0x8a,0xf6,0x04,0x65,0xf4,0x29,0x86};
    std::uint8_t ret77[32] = {0x1c,0xa2,0x99,0xb5,0xea,0x8d,0x8c,0x0a,0xd5,0x7b,0x8c,0xf9,0xfe,0xb4,0x1b,0x9d,0x94,0xd6,0x78,0xd2,0xbe,0x5e,0x8f,0xad,0x71,0x45,0x7b,0x02,0x32,0xfa,0x14,0xc3};
    mont256_from_bytes(&ctx, num, num77);
    mont256_div2(&ctx, ret, num);
    mont256_to_bytes(&ctx, ret_data, ret);
    if (std::memcmp(ret77, ret_data, 32) != 0)
    {
        throw std::runtime_error("err in mont256_div2");
    }
    std::uint8_t num78[32] = {0x6b,0xd8,0xc6,0x76,0x56,0xd0,0x50,0xcd,0x67,0x60,0x13,0x67,0x83,0xfe,0xb1,0x7b,0xfe,0x7b,0x8a,0xe4,0x6e,0x78,0x36,0xa4,0xb4,0xd1,0x9e,0xc1,0x29,0x55,0xd6,0xf0};
    std::uint8_t ret78[32] = {0x35,0xec,0x63,0x3b,0x2b,0x68,0x28,0x66,0xb3,0xb0,0x09,0xb3,0xc1,0xff,0x58,0xbd,0xff,0x3d,0xc5,0x72,0x37,0x3c,0x1b,0x52,0x5a,0x68,0xcf,0x60,0x94,0xaa,0xeb,0x78};
    mont256_from_bytes(&ctx, num, num78);
    mont256_div2(&ctx, ret, num);
    mont256_to_bytes(&ctx, ret_data, ret);
    if (std::memcmp(ret78, ret_data, 32) != 0)
    {
        throw std::runtime_error("err in mont256_div2");
    }
    std::uint8_t num79[32] = {0x56,0x85,0xd6,0x24,0x04,0xfc,0xd5,0x55,0x5d,0xaf,0x10,0x6d,0xb8,0xde,0xe0,0x81,0x17,0x9a,0x07,0x1e,0x51,0x8a,0xe4,0x52,0x5b,0x4b,0x1b,0x75,0x32,0x1c,0x52,0x96};
    std::uint8_t ret79[32] = {0x2b,0x42,0xeb,0x12,0x02,0x7e,0x6a,0xaa,0xae,0xd7,0x88,0x36,0xdc,0x6f,0x70,0x40,0x8b,0xcd,0x03,0x8f,0x28,0xc5,0x72,0x29,0x2d,0xa5,0x8d,0xba,0x99,0x0e,0x29,0x4b};
    mont256_from_bytes(&ctx, num, num79);
    mont256_div2(&ctx, ret, num);
    mont256_to_bytes(&ctx, ret_data, ret);
    if (std::memcmp(ret79, ret_data, 32) != 0)
    {
        throw std::runtime_error("err in mont256_div2");
    }
    std::uint8_t num80[32] = {0x84,0x76,0x8b,0x8c,0x54,0xdd,0x0b,0xa5,0x62,0x64,0x67,0xba,0x04,0xa1,0x05,0x47,0xb4,0x01,0xba,0x85,0x70,0xc1,0xdc,0xa1,0x75,0x6b,0x72,0x89,0x8d,0xd6,0x3c,0xb9};
    std::uint8_t ret80[32] = {0xc2,0x3b,0x45,0xc5,0xaa,0x6e,0x85,0xd2,0xb1,0x32,0x33,0xdd,0x02,0x50,0x82,0xa3,0xda,0x00,0xdd,0x42,0x38,0x60,0xee,0x51,0x3a,0xb5,0xb9,0x44,0xc6,0xeb,0x1e,0x5c};
    mont256_from_bytes(&ctx, num, num80);
    mont256_div2(&ctx, ret, num);
    mont256_to_bytes(&ctx, ret_data, ret);
    if (std::memcmp(ret80, ret_data, 32) != 0)
    {
        throw std::runtime_error("err in mont256_div2");
    }
    std::uint8_t num81[32] = {0xeb,0x25,0xf8,0xa1,0xfc,0x2e,0x6a,0x59,0x1c,0xe3,0xbc,0x0c,0x10,0x75,0x5c,0x97,0xf5,0xf5,0x54,0xed,0x83,0x23,0x9e,0xf5,0x4b,0xa2,0xe1,0x61,0x9f,0xb9,0xaf,0x50};
    std::uint8_t ret81[32] = {0x75,0x92,0xfc,0x50,0xfe,0x17,0x35,0x2c,0x8e,0x71,0xde,0x06,0x08,0x3a,0xae,0x4b,0xfa,0xfa,0xaa,0x76,0xc1,0x91,0xcf,0x7a,0xa5,0xd1,0x70,0xb0,0xcf,0xdc,0xd7,0xa8};
    mont256_from_bytes(&ctx, num, num81);
    mont256_div2(&ctx, ret, num);
    mont256_to_bytes(&ctx, ret_data, ret);
    if (std::memcmp(ret81, ret_data, 32) != 0)
    {
        throw std::runtime_error("err in mont256_div2");
    }
    std::uint8_t num82[32] = {0x45,0x9c,0x94,0x5c,0x43,0xfc,0x05,0x27,0x15,0x85,0x0a,0x03,0x1a,0xd2,0xd5,0xf1,0xe0,0x5b,0x3e,0x13,0xf8,0xc1,0x10,0xfb,0x3a,0x82,0x81,0x59,0xc9,0xd2,0x29,0x50};
    std::uint8_t ret82[32] = {0x22,0xce,0x4a,0x2e,0x21,0xfe,0x02,0x93,0x8a,0xc2,0x85,0x01,0x8d,0x69,0x6a,0xf8,0xf0,0x2d,0x9f,0x09,0xfc,0x60,0x88,0x7d,0x9d,0x41,0x40,0xac,0xe4,0xe9,0x14,0xa8};
    mont256_from_bytes(&ctx, num, num82);
    mont256_div2(&ctx, ret, num);
    mont256_to_bytes(&ctx, ret_data, ret);
    if (std::memcmp(ret82, ret_data, 32) != 0)
    {
        throw std::runtime_error("err in mont256_div2");
    }
    std::uint8_t num83[32] = {0xd1,0xdc,0xec,0x53,0x21,0x2a,0x8d,0x9b,0xc1,0x7a,0x92,0x62,0x45,0x3b,0xf4,0x91,0x2e,0x7a,0x26,0xe9,0xc7,0x6c,0x60,0x3f,0xe7,0xe8,0xf9,0xf6,0x0a,0x22,0x73,0x85};
    std::uint8_t ret83[32] = {0xe8,0xee,0x76,0x29,0x10,0x95,0x46,0xcd,0xe0,0xbd,0x49,0x31,0x22,0x9d,0xfa,0x48,0x97,0x3d,0x13,0x74,0x63,0xb6,0x30,0x20,0x73,0xf4,0x7c,0xfb,0x05,0x11,0x39,0xc2};
    mont256_from_bytes(&ctx, num, num83);
    mont256_div2(&ctx, ret, num);
    mont256_to_bytes(&ctx, ret_data, ret);
    if (std::memcmp(ret83, ret_data, 32) != 0)
    {
        throw std::runtime_error("err in mont256_div2");
    }
    std::uint8_t num84[32] = {0x67,0xec,0x32,0x6a,0x42,0x34,0x33,0x54,0xf2,0x2d,0x28,0x82,0xd1,0xa8,0x9b,0x37,0xad,0x0c,0x9b,0xb6,0xe9,0x52,0x6a,0x69,0xd9,0x7e,0x96,0x7b,0x6c,0x18,0xd9,0x82};
    std::uint8_t ret84[32] = {0x33,0xf6,0x19,0x35,0x21,0x1a,0x19,0xaa,0x79,0x16,0x94,0x41,0x68,0xd4,0x4d,0x9b,0xd6,0x86,0x4d,0xdb,0x74,0xa9,0x35,0x34,0xec,0xbf,0x4b,0x3d,0xb6,0x0c,0x6c,0xc1};
    mont256_from_bytes(&ctx, num, num84);
    mont256_div2(&ctx, ret, num);
    mont256_to_bytes(&ctx, ret_data, ret);
    if (std::memcmp(ret84, ret_data, 32) != 0)
    {
        throw std::runtime_error("err in mont256_div2");
    }
    std::uint8_t num85[32] = {0x53,0xb9,0x73,0x77,0xb3,0x4e,0x8e,0xce,0x7e,0x9e,0xe5,0x1d,0x92,0x12,0x82,0x4c,0x83,0xc8,0xcb,0x28,0xeb,0x4e,0xd2,0xe3,0x89,0x5e,0x8b,0x6b,0x26,0x3c,0xfa,0x5e};
    std::uint8_t ret85[32] = {0x29,0xdc,0xb9,0xbb,0xd9,0xa7,0x47,0x67,0x3f,0x4f,0x72,0x8e,0xc9,0x09,0x41,0x26,0x41,0xe4,0x65,0x94,0x75,0xa7,0x69,0x71,0xc4,0xaf,0x45,0xb5,0x93,0x1e,0x7d,0x2f};
    mont256_from_bytes(&ctx, num, num85);
    mont256_div2(&ctx, ret, num);
    mont256_to_bytes(&ctx, ret_data, ret);
    if (std::memcmp(ret85, ret_data, 32) != 0)
    {
        throw std::runtime_error("err in mont256_div2");
    }
    std::uint8_t num86[32] = {0xe5,0x31,0x69,0x60,0x6c,0xe1,0x93,0xc2,0x2e,0xef,0xa2,0x79,0xb0,0x2e,0x3d,0x8d,0xcc,0xb1,0xc5,0x1d,0x0e,0xba,0x0e,0xa8,0x47,0x70,0xa0,0x87,0x16,0xe6,0xfe,0xc3};
    std::uint8_t ret86[32] = {0xf2,0x98,0xb4,0xaf,0xb6,0x70,0xc9,0xe1,0x17,0x77,0xd1,0x3c,0xd8,0x17,0x1e,0xc6,0xe6,0x58,0xe2,0x8e,0x07,0x5d,0x07,0x54,0xa3,0xb8,0x50,0x43,0x8b,0x73,0x7f,0x61};
    mont256_from_bytes(&ctx, num, num86);
    mont256_div2(&ctx, ret, num);
    mont256_to_bytes(&ctx, ret_data, ret);
    if (std::memcmp(ret86, ret_data, 32) != 0)
    {
        throw std::runtime_error("err in mont256_div2");
    }
    std::uint8_t num87[32] = {0x42,0xb3,0x87,0x55,0xcd,0x37,0x88,0x0e,0x16,0xac,0x41,0x91,0xa2,0x6a,0xa0,0xae,0x04,0x4f,0x15,0x74,0xf0,0x37,0xaf,0xc6,0x44,0xd8,0x2a,0x53,0x12,0x89,0xba,0xfa};
    std::uint8_t ret87[32] = {0x21,0x59,0xc3,0xaa,0xe6,0x9b,0xc4,0x07,0x0b,0x56,0x20,0xc8,0xd1,0x35,0x50,0x57,0x02,0x27,0x8a,0xba,0x78,0x1b,0xd7,0xe3,0x22,0x6c,0x15,0x29,0x89,0x44,0xdd,0x7d};
    mont256_from_bytes(&ctx, num, num87);
    mont256_div2(&ctx, ret, num);
    mont256_to_bytes(&ctx, ret_data, ret);
    if (std::memcmp(ret87, ret_data, 32) != 0)
    {
        throw std::runtime_error("err in mont256_div2");
    }
    std::uint8_t num88[32] = {0x1f,0x26,0x42,0xaa,0xdc,0xde,0xd2,0x04,0x43,0xb3,0x0f,0x66,0x11,0x0e,0x2c,0xb6,0x38,0xef,0xba,0xeb,0xdb,0x31,0xcc,0xd2,0x9b,0xb1,0x83,0xe1,0x15,0x70,0x26,0x6b};
    std::uint8_t ret88[32] = {0x8f,0x93,0x21,0x54,0xee,0x6f,0x69,0x02,0x21,0xd9,0x87,0xb3,0x08,0x87,0x16,0x5b,0x1c,0x77,0xdd,0x75,0x6d,0x98,0xe6,0x69,0xcd,0xd8,0xc1,0xf0,0x8a,0xb8,0x13,0x35};
    mont256_from_bytes(&ctx, num, num88);
    mont256_div2(&ctx, ret, num);
    mont256_to_bytes(&ctx, ret_data, ret);
    if (std::memcmp(ret88, ret_data, 32) != 0)
    {
        throw std::runtime_error("err in mont256_div2");
    }
    std::uint8_t num89[32] = {0xea,0x59,0x67,0x9a,0xed,0x3a,0x32,0xa8,0x6a,0xf2,0x57,0x48,0x8d,0x95,0x9c,0x31,0xfe,0x8a,0xd4,0xa1,0x56,0xd2,0xa6,0x8c,0x02,0xf4,0xb3,0x42,0x74,0x2a,0x80,0x63};
    std::uint8_t ret89[32] = {0xf5,0x2c,0xb3,0xcc,0xf6,0x9d,0x19,0x54,0x35,0x79,0x2b,0xa4,0x46,0xca,0xce,0x18,0xff,0x45,0x6a,0x50,0x2b,0x69,0x53,0x46,0x81,0x7a,0x59,0xa1,0x3a,0x15,0x40,0x31};
    mont256_from_bytes(&ctx, num, num89);
    mont256_div2(&ctx, ret, num);
    mont256_to_bytes(&ctx, ret_data, ret);
    if (std::memcmp(ret89, ret_data, 32) != 0)
    {
        throw std::runtime_error("err in mont256_div2");
    }
    std::uint8_t num90[32] = {0xf0,0x29,0x05,0x31,0x3d,0x0a,0x27,0x0b,0xb5,0xa4,0x32,0xcf,0x86,0xe3,0xe7,0x26,0x0b,0x0f,0x87,0x3b,0x21,0x14,0xe0,0x68,0x9f,0x27,0xf5,0x2c,0x44,0x92,0x74,0xd2};
    std::uint8_t ret90[32] = {0x78,0x14,0x82,0x98,0x9e,0x85,0x13,0x85,0xda,0xd2,0x19,0x67,0xc3,0x71,0xf3,0x93,0x05,0x87,0xc3,0x9d,0x90,0x8a,0x70,0x34,0x4f,0x93,0xfa,0x96,0x22,0x49,0x3a,0x69};
    mont256_from_bytes(&ctx, num, num90);
    mont256_div2(&ctx, ret, num);
    mont256_to_bytes(&ctx, ret_data, ret);
    if (std::memcmp(ret90, ret_data, 32) != 0)
    {
        throw std::runtime_error("err in mont256_div2");
    }
    std::uint8_t num91[32] = {0xee,0xa7,0xbb,0x64,0x33,0xa7,0x15,0x68,0x2e,0x5f,0x95,0x0c,0x0c,0xe5,0xaf,0x69,0x43,0x0b,0x91,0xed,0x29,0x54,0xba,0x5c,0xf8,0x1e,0x54,0xdd,0x1c,0x05,0x02,0xc6};
    std::uint8_t ret91[32] = {0x77,0x53,0xdd,0xb2,0x19,0xd3,0x8a,0xb4,0x17,0x2f,0xca,0x86,0x06,0x72,0xd7,0xb4,0xa1,0x85,0xc8,0xf6,0x94,0xaa,0x5d,0x2e,0x7c,0x0f,0x2a,0x6e,0x8e,0x02,0x81,0x63};
    mont256_from_bytes(&ctx, num, num91);
    mont256_div2(&ctx, ret, num);
    mont256_to_bytes(&ctx, ret_data, ret);
    if (std::memcmp(ret91, ret_data, 32) != 0)
    {
        throw std::runtime_error("err in mont256_div2");
    }
    std::uint8_t num92[32] = {0x72,0x18,0x88,0xff,0x4a,0x3a,0xdf,0x99,0x34,0xb3,0xff,0x60,0xc2,0x6e,0x7a,0x42,0x87,0xf5,0x3d,0xdd,0x4e,0x14,0xd5,0x71,0xa0,0xf0,0x96,0xda,0x4f,0xde,0xbb,0xec};
    std::uint8_t ret92[32] = {0x39,0x0c,0x44,0x7f,0xa5,0x1d,0x6f,0xcc,0x9a,0x59,0xff,0xb0,0x61,0x37,0x3d,0x21,0x43,0xfa,0x9e,0xee,0xa7,0x0a,0x6a,0xb8,0xd0,0x78,0x4b,0x6d,0x27,0xef,0x5d,0xf6};
    mont256_from_bytes(&ctx, num, num92);
    mont256_div2(&ctx, ret, num);
    mont256_to_bytes(&ctx, ret_data, ret);
    if (std::memcmp(ret92, ret_data, 32) != 0)
    {
        throw std::runtime_error("err in mont256_div2");
    }
    std::uint8_t num93[32] = {0xfe,0x97,0x7c,0x56,0x04,0xa6,0x56,0x51,0xcd,0xbd,0xe7,0x47,0x58,0xd5,0x0f,0x1b,0x45,0x40,0xf4,0x26,0x2d,0x8a,0xd8,0xc0,0xac,0x12,0x7e,0x93,0x80,0x05,0xce,0x74};
    std::uint8_t ret93[32] = {0x7f,0x4b,0xbe,0x2b,0x02,0x53,0x2b,0x28,0xe6,0xde,0xf3,0xa3,0xac,0x6a,0x87,0x8d,0xa2,0xa0,0x7a,0x13,0x16,0xc5,0x6c,0x60,0x56,0x09,0x3f,0x49,0xc0,0x02,0xe7,0x3a};
    mont256_from_bytes(&ctx, num, num93);
    mont256_div2(&ctx, ret, num);
    mont256_to_bytes(&ctx, ret_data, ret);
    if (std::memcmp(ret93, ret_data, 32) != 0)
    {
        throw std::runtime_error("err in mont256_div2");
    }
    std::uint8_t num94[32] = {0xfa,0x61,0x97,0x74,0x8d,0x11,0x8e,0x37,0x81,0x72,0x8a,0x07,0xbb,0xab,0x27,0xf6,0x04,0xb8,0x15,0x7d,0x03,0xed,0xb9,0x20,0x09,0x75,0x83,0x40,0x40,0x1d,0x68,0xfb};
    std::uint8_t ret94[32] = {0xfd,0x30,0xcb,0xb9,0xc6,0x88,0xc7,0x1b,0xc0,0xb9,0x45,0x03,0xdd,0xd5,0x93,0xfb,0x02,0x5c,0x0a,0xbe,0x01,0xf6,0xdc,0x90,0x84,0xba,0xc1,0xa0,0x20,0x0e,0xb4,0x7d};
    mont256_from_bytes(&ctx, num, num94);
    mont256_div2(&ctx, ret, num);
    mont256_to_bytes(&ctx, ret_data, ret);
    if (std::memcmp(ret94, ret_data, 32) != 0)
    {
        throw std::runtime_error("err in mont256_div2");
    }
    std::uint8_t num95[32] = {0xa8,0x87,0xae,0x22,0x1b,0x35,0x41,0x1b,0x72,0x72,0x3b,0x9c,0xef,0x44,0xc0,0xd5,0x3e,0xe4,0xda,0x5a,0x79,0x89,0xe9,0xd0,0x83,0xa4,0xe6,0x29,0x30,0x80,0x38,0x89};
    std::uint8_t ret95[32] = {0xd4,0x43,0xd7,0x10,0x8d,0x9a,0xa0,0x8d,0xb9,0x39,0x1d,0xce,0x77,0xa2,0x60,0x6a,0x9f,0x72,0x6d,0x2c,0xbc,0xc4,0xf4,0xe8,0xc1,0xd2,0x73,0x14,0x98,0x40,0x1c,0x44};
    mont256_from_bytes(&ctx, num, num95);
    mont256_div2(&ctx, ret, num);
    mont256_to_bytes(&ctx, ret_data, ret);
    if (std::memcmp(ret95, ret_data, 32) != 0)
    {
        throw std::runtime_error("err in mont256_div2");
    }
    std::uint8_t num96[32] = {0xe3,0x83,0x8b,0x9e,0xd5,0xa9,0x42,0x2a,0x8b,0xc0,0x83,0x11,0x7e,0xb8,0x6c,0x57,0xa8,0x11,0x00,0xa1,0x6e,0xa3,0x30,0xa1,0xa6,0x6d,0x58,0xb5,0xd1,0xa4,0xc0,0x1e};
    std::uint8_t ret96[32] = {0x71,0xc1,0xc5,0xcf,0x6a,0xd4,0xa1,0x15,0x45,0xe0,0x41,0x88,0xbf,0x5c,0x36,0x2b,0xd4,0x08,0x80,0x50,0xb7,0x51,0x98,0x50,0xd3,0x36,0xac,0x5a,0xe8,0xd2,0x60,0x0f};
    mont256_from_bytes(&ctx, num, num96);
    mont256_div2(&ctx, ret, num);
    mont256_to_bytes(&ctx, ret_data, ret);
    if (std::memcmp(ret96, ret_data, 32) != 0)
    {
        throw std::runtime_error("err in mont256_div2");
    }
    std::uint8_t num97[32] = {0x3a,0xc4,0xda,0x9a,0xfb,0x81,0x39,0x21,0x37,0x16,0x1c,0x16,0xb0,0x0f,0xd7,0xbb,0x4e,0xca,0xde,0xa2,0x81,0xb6,0x2b,0xb5,0xf8,0x66,0x64,0xae,0x64,0xa1,0x49,0xf5};
    std::uint8_t ret97[32] = {0x9d,0x62,0x6d,0x4c,0xfd,0xc0,0x9c,0x90,0x9b,0x8b,0x0e,0x0b,0x58,0x07,0xeb,0xdd,0xa7,0x65,0x6f,0x50,0xc0,0xdb,0x15,0xdb,0x7c,0x33,0x32,0x57,0x32,0x50,0xa4,0xfa};
    mont256_from_bytes(&ctx, num, num97);
    mont256_div2(&ctx, ret, num);
    mont256_to_bytes(&ctx, ret_data, ret);
    if (std::memcmp(ret97, ret_data, 32) != 0)
    {
        throw std::runtime_error("err in mont256_div2");
    }
    std::uint8_t num98[32] = {0x23,0xc4,0x9c,0xae,0xa2,0xcf,0x62,0xba,0xba,0x95,0x88,0x10,0xb4,0xeb,0xf4,0xb6,0xe1,0xc6,0x0a,0xa3,0xd5,0x10,0xbb,0x04,0x32,0xd9,0x0d,0xcd,0x57,0xbb,0x7d,0x97};
    std::uint8_t ret98[32] = {0x91,0xe2,0x4e,0x56,0xd1,0x67,0xb1,0x5d,0x5d,0x4a,0xc4,0x08,0x5a,0x75,0xfa,0x5b,0x70,0xe3,0x05,0x51,0x6a,0x88,0x5d,0x82,0x99,0x6c,0x86,0xe6,0xab,0xdd,0xbe,0xcb};
    mont256_from_bytes(&ctx, num, num98);
    mont256_div2(&ctx, ret, num);
    mont256_to_bytes(&ctx, ret_data, ret);
    if (std::memcmp(ret98, ret_data, 32) != 0)
    {
        throw std::runtime_error("err in mont256_div2");
    }
    std::uint8_t num99[32] = {0x03,0xa6,0x39,0x66,0x21,0x3b,0xca,0x7f,0xd6,0x44,0xde,0x2f,0x0d,0xec,0x68,0x23,0xfb,0x5c,0x9d,0x56,0x58,0xf9,0x2d,0xea,0xfd,0x4b,0xd0,0x30,0x67,0x9a,0x44,0xdd};
    std::uint8_t ret99[32] = {0x81,0xd3,0x1c,0xb2,0x90,0x9d,0xe5,0x3f,0xeb,0x22,0x6f,0x17,0x86,0xf6,0x34,0x11,0xfd,0xae,0x4e,0xaa,0xac,0x7c,0x96,0xf5,0xfe,0xa5,0xe8,0x18,0x33,0xcd,0x22,0x6e};
    mont256_from_bytes(&ctx, num, num99);
    mont256_div2(&ctx, ret, num);
    mont256_to_bytes(&ctx, ret_data, ret);
    if (std::memcmp(ret99, ret_data, 32) != 0)
    {
        throw std::runtime_error("err in mont256_div2");
    }
}
